Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,14 @@
|
|
1 |
import gradio_client
|
2 |
from gradio_client import Client, file
|
3 |
from urllib.parse import quote
|
4 |
-
|
5 |
-
|
6 |
import numpy as np
|
7 |
import gradio as gr
|
|
|
8 |
def generate_img(prompt):
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
prompt=prompt,
|
13 |
-
api_name="/generate_image"
|
14 |
-
)
|
15 |
-
return result
|
16 |
|
17 |
def pollinations_url_seedless(a, width=512, height=512):
|
18 |
urlprompt=quote(str(a))
|
@@ -20,17 +16,8 @@ def pollinations_url_seedless(a, width=512, height=512):
|
|
20 |
return url
|
21 |
|
22 |
def interrogate(img):
|
23 |
-
|
24 |
-
|
25 |
-
# client.view_api()
|
26 |
-
client = Client("https://pharmapsychotic-clip-interrogator.hf.space/")
|
27 |
-
client.view_api()
|
28 |
-
result = client.predict(
|
29 |
-
img, # str (filepath or URL to image)
|
30 |
-
"ViT-L (best for Stable Diffusion 1.*)", # str (Option from: ['ViT-L (best for Stable Diffusion 1.*)'])
|
31 |
-
"best", # str in 'Mode' Radio component
|
32 |
-
fn_index=3
|
33 |
-
)
|
34 |
return result
|
35 |
def rountrip(img):
|
36 |
prompt=interrogate(img)
|
|
|
1 |
import gradio_client
|
2 |
from gradio_client import Client, file
|
3 |
from urllib.parse import quote
|
4 |
+
from huggingface_hub import InferenceClient
|
|
|
5 |
import numpy as np
|
6 |
import gradio as gr
|
7 |
+
client = InferenceClient()
|
8 |
def generate_img(prompt):
|
9 |
+
|
10 |
+
|
11 |
+
return client.text_to_image(prompt)
|
|
|
|
|
|
|
|
|
12 |
|
13 |
def pollinations_url_seedless(a, width=512, height=512):
|
14 |
urlprompt=quote(str(a))
|
|
|
16 |
return url
|
17 |
|
18 |
def interrogate(img):
|
19 |
+
|
20 |
+
result = client.image_to_text(img)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
return result
|
22 |
def rountrip(img):
|
23 |
prompt=interrogate(img)
|