Spaces:
Runtime error
Runtime error
update grid layout
Browse files
app.py
CHANGED
|
@@ -22,10 +22,7 @@ def process_response(response_dict):
|
|
| 22 |
|
| 23 |
response_dict = get_initial_images()
|
| 24 |
initial = process_response(response_dict)
|
| 25 |
-
initial_imgs = '<div style="display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); grid-gap: 0;
|
| 26 |
-
#print(initial_imgs )
|
| 27 |
-
#print("*****************")
|
| 28 |
-
#response_dict
|
| 29 |
|
| 30 |
#Third: Load more images for the grid
|
| 31 |
def get_next10_images(response_dict, row_count):
|
|
@@ -41,20 +38,10 @@ def get_next10_images(response_dict, row_count):
|
|
| 41 |
#print("(2)",type(response))
|
| 42 |
#print("(3)",type(response['data'][0]))
|
| 43 |
next_set = [resp[0][:-1] for resp in response_dict["data"]]
|
| 44 |
-
next_set_images = '<div style="display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); grid-gap: 0;
|
| 45 |
return response['data'][0], row_count, next_set_images
|
| 46 |
|
| 47 |
-
get_next10_images(response_dict=response_dict, row_count=9)
|
| 48 |
-
|
| 49 |
-
#def process_response(response_dict):
|
| 50 |
-
# return [resp[0][:-1] for resp in response_dict["data"]]
|
| 51 |
-
|
| 52 |
-
#response_dict = get_initial_images()
|
| 53 |
-
#initial = process_response(response_dict)
|
| 54 |
-
#initial_imgs = '<div style="display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); grid-gap: 0;">\n' + "\n".join(initial[:-1])
|
| 55 |
-
#print(initial_imgs )
|
| 56 |
-
#print("*****************")
|
| 57 |
-
#response_dict
|
| 58 |
|
| 59 |
#Defining the Blocks layout
|
| 60 |
with gr.Blocks(css = """#img_search img {width: 100%; height: 100%; object-fit: cover;}""") as demo:
|
|
@@ -91,8 +78,6 @@ with gr.Blocks(css = """#img_search img {width: 100%; height: 100%; object-fit:
|
|
| 91 |
gr.HTML('''<center><a href="https://huggingface.co/spaces/ysharma/Blip_PlaygroundAI?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a></center>
|
| 92 |
</p></div>''')
|
| 93 |
gr.HTML(value='<a href="#top">go ot top</a>', elem_id="bottom",)
|
| 94 |
-
#image_in.change(Image_similarity_search, [image_in, search_query], [img_search], api_name="PlaygroundAI_image_search" )
|
| 95 |
-
#search_query.submit(Image_similarity_search, [image_in, search_query], [img_search], api_name='PlaygroundAI_text_search' )
|
| 96 |
b1.click(get_next10_images, [df, row_count], [df, row_count, img_search], api_name = "load_playgroundai_images" )
|
| 97 |
|
| 98 |
demo.launch(debug=True)
|
|
|
|
| 22 |
|
| 23 |
response_dict = get_initial_images()
|
| 24 |
initial = process_response(response_dict)
|
| 25 |
+
initial_imgs = '<div style="display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); grid-gap: 0; ">\n' + "\n".join(initial[:-1])
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
#Third: Load more images for the grid
|
| 28 |
def get_next10_images(response_dict, row_count):
|
|
|
|
| 38 |
#print("(2)",type(response))
|
| 39 |
#print("(3)",type(response['data'][0]))
|
| 40 |
next_set = [resp[0][:-1] for resp in response_dict["data"]]
|
| 41 |
+
next_set_images = '<div style="display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); grid-gap: 0; ">\n' + "\n".join(next_set[:-1])
|
| 42 |
return response['data'][0], row_count, next_set_images
|
| 43 |
|
| 44 |
+
#get_next10_images(response_dict=response_dict, row_count=9)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
#Defining the Blocks layout
|
| 47 |
with gr.Blocks(css = """#img_search img {width: 100%; height: 100%; object-fit: cover;}""") as demo:
|
|
|
|
| 78 |
gr.HTML('''<center><a href="https://huggingface.co/spaces/ysharma/Blip_PlaygroundAI?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a></center>
|
| 79 |
</p></div>''')
|
| 80 |
gr.HTML(value='<a href="#top">go ot top</a>', elem_id="bottom",)
|
|
|
|
|
|
|
| 81 |
b1.click(get_next10_images, [df, row_count], [df, row_count, img_search], api_name = "load_playgroundai_images" )
|
| 82 |
|
| 83 |
demo.launch(debug=True)
|