Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,12 +21,13 @@ def swap_gallery(im, images):
|
|
21 |
return list(map(lambda x: x["name"], t2_list))
|
22 |
|
23 |
|
24 |
-
def lexica(prompt, limit_size = 128):
|
25 |
lex = Lexica(query=prompt).images()
|
26 |
lex = lex[:limit_size]
|
27 |
lex = list(map(lambda ele: Image.open(
|
28 |
requests.get(ele, stream = True).raw
|
29 |
), lex))
|
|
|
30 |
return lex
|
31 |
|
32 |
with gr.Blocks() as demo:
|
@@ -40,10 +41,10 @@ with gr.Blocks() as demo:
|
|
40 |
outputs = gr.Gallery(lable='Output gallery').style(grid=3,height=768,
|
41 |
allow_preview=False)
|
42 |
#gr.Dataframe(label='prompts for corresponding images')]
|
43 |
-
|
44 |
-
#outputs.select(image_click, outputs, i, _js="(x) => x.splice(0,x.length)")
|
45 |
outputs.select(image_click, outputs, i,)
|
46 |
-
|
47 |
i.change(
|
48 |
fn=swap_gallery,
|
49 |
inputs=[i, outputs],
|
@@ -54,4 +55,4 @@ with gr.Blocks() as demo:
|
|
54 |
|
55 |
text_button.click(lexica, inputs=inputs, outputs=outputs)
|
56 |
|
57 |
-
demo.launch("0.0.0.0" ,debug = True)
|
|
|
21 |
return list(map(lambda x: x["name"], t2_list))
|
22 |
|
23 |
|
24 |
+
def lexica(prompt, limit_size = 128, resize = (512, 512)):
|
25 |
lex = Lexica(query=prompt).images()
|
26 |
lex = lex[:limit_size]
|
27 |
lex = list(map(lambda ele: Image.open(
|
28 |
requests.get(ele, stream = True).raw
|
29 |
), lex))
|
30 |
+
lex = list(map(lambda x: x.resize(resize), lex))
|
31 |
return lex
|
32 |
|
33 |
with gr.Blocks() as demo:
|
|
|
41 |
outputs = gr.Gallery(lable='Output gallery').style(grid=3,height=768,
|
42 |
allow_preview=False)
|
43 |
#gr.Dataframe(label='prompts for corresponding images')]
|
44 |
+
|
45 |
+
#outputs.select(image_click, outputs, i, _js="(x) => x.splice(0,x.length)")
|
46 |
outputs.select(image_click, outputs, i,)
|
47 |
+
|
48 |
i.change(
|
49 |
fn=swap_gallery,
|
50 |
inputs=[i, outputs],
|
|
|
55 |
|
56 |
text_button.click(lexica, inputs=inputs, outputs=outputs)
|
57 |
|
58 |
+
demo.launch("0.0.0.0" ,debug = True)
|