Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -40,13 +40,31 @@ def lexica(prompt, limit_size = 128, ratio_size = 256 + 128):
|
|
40 |
lex = list(map(lambda x: min_dim_to_size(x, ratio_size)[1], lex))
|
41 |
return lex
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
with gr.Blocks() as demo:
|
44 |
with gr.Row():
|
45 |
with gr.Column():
|
46 |
with gr.Row():
|
47 |
#inputs = gr.Textbox(label = 'Enter prompt to search Lexica.art')
|
48 |
inputs = gr.Textbox(label="Prompt", show_label=False, lines=1, max_lines=20, min_width = 256,
|
49 |
-
placeholder="Enter prompt to search
|
50 |
#gr.Slider(label='Number of images ', minimum = 4, maximum = 20, step = 1, value = 4)]
|
51 |
text_button = gr.Button("Retrieve Images", elem_id="run_button")
|
52 |
i = gr.Image(elem_id="result-image")
|
@@ -72,6 +90,9 @@ with gr.Blocks() as demo:
|
|
72 |
)
|
73 |
#### gr.Textbox().submit().success()
|
74 |
|
75 |
-
|
|
|
|
|
|
|
76 |
|
77 |
demo.launch("0.0.0.0")
|
|
|
40 |
lex = list(map(lambda x: min_dim_to_size(x, ratio_size)[1], lex))
|
41 |
return lex
|
42 |
|
43 |
+
def enterpix(prompt, limit_size = 100, ratio_size = 256 + 128, use_key = "bigThumbnailUrl"):
|
44 |
+
resp = requests.post(
|
45 |
+
url = "https://www.enterpix.app/enterpix/v1/image/prompt-search",
|
46 |
+
data= {
|
47 |
+
"length": limit_size,
|
48 |
+
"platform": "stable-diffusion,midjourney",
|
49 |
+
"prompt": prompt,
|
50 |
+
"start": 0
|
51 |
+
}
|
52 |
+
)
|
53 |
+
resp = resp.json()
|
54 |
+
resp = list(map(lambda x: x[use_key], resp["images"]))
|
55 |
+
resp = list(map(lambda ele: Image.open(
|
56 |
+
requests.get(ele, stream = True).raw
|
57 |
+
), resp))
|
58 |
+
resp = list(map(lambda x: min_dim_to_size(x, ratio_size)[1], resp))
|
59 |
+
return resp
|
60 |
+
|
61 |
with gr.Blocks() as demo:
|
62 |
with gr.Row():
|
63 |
with gr.Column():
|
64 |
with gr.Row():
|
65 |
#inputs = gr.Textbox(label = 'Enter prompt to search Lexica.art')
|
66 |
inputs = gr.Textbox(label="Prompt", show_label=False, lines=1, max_lines=20, min_width = 256,
|
67 |
+
placeholder="Enter prompt to search", elem_id="prompt")
|
68 |
#gr.Slider(label='Number of images ', minimum = 4, maximum = 20, step = 1, value = 4)]
|
69 |
text_button = gr.Button("Retrieve Images", elem_id="run_button")
|
70 |
i = gr.Image(elem_id="result-image")
|
|
|
90 |
)
|
91 |
#### gr.Textbox().submit().success()
|
92 |
|
93 |
+
### lexica
|
94 |
+
#text_button.click(lexica, inputs=inputs, outputs=outputs)
|
95 |
+
### enterpix
|
96 |
+
text_button.click(enterpix, inputs=inputs, outputs=outputs)
|
97 |
|
98 |
demo.launch("0.0.0.0")
|