Spaces:
Runtime error
Runtime error
restructured with Blocks
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ img_df = pd.read_csv('image_data.csv')
|
|
21 |
|
22 |
def url2img(url):
|
23 |
data = requests.get(url, allow_redirects = True).content
|
24 |
-
|
25 |
return data
|
26 |
|
27 |
def find_topk(text):
|
@@ -63,9 +63,23 @@ def find_topk(text):
|
|
63 |
#demo = gr.Interface(find_topk, inputs = 'text', outputs = 'image')
|
64 |
|
65 |
print('version', gr.__version__)
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
if __name__ == "__main__":
|
71 |
demo.launch()
|
|
|
21 |
|
22 |
def url2img(url):
|
23 |
data = requests.get(url, allow_redirects = True).content
|
24 |
+
return Image.open(io.BytesIO(data))
|
25 |
return data
|
26 |
|
27 |
def find_topk(text):
|
|
|
63 |
#demo = gr.Interface(find_topk, inputs = 'text', outputs = 'image')
|
64 |
|
65 |
print('version', gr.__version__)
|
66 |
+
|
67 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
68 |
+
gr.Markdown('# Enter a prompt in one of the supported languages.')
|
69 |
+
with gr.Row():
|
70 |
+
gr.Markdown('| Code | Language | # | Code | Language | # | Code | Language |'
|
71 |
+
'| :------- | :------- | :--- | :------- | :------------------- | :--- | :------- | :------- |'
|
72 |
+
'| eng_Latn | English | # | fra_Latn | French | # | kor_Hang | Korean |'
|
73 |
+
'| deu_Latn | German | # | ita_Latn | Italian | # | pol_Latn | Polish |'
|
74 |
+
'| ita_Latn | Spanish | # | jpn_Jpan | Japanese | # | rus_Cyrl | Russian |'
|
75 |
+
'| tur_Latn | Turkish | # | zho_Hans | Chinese (Simplified) | # | . | . |')
|
76 |
+
|
77 |
+
with gr.Column():
|
78 |
+
prompt_box = gr.Textbox(label = 'Enter your prompt', lines = 2)
|
79 |
+
btn_search = gr.Button("Find images")
|
80 |
+
|
81 |
+
gallery = gr.Gallery()
|
82 |
+
btn_search.click(find_topk, inputs = prompt_box, outputs = gallery)
|
83 |
+
|
84 |
if __name__ == "__main__":
|
85 |
demo.launch()
|