Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import os | |
| import random | |
| from src.model import simlarity_model as model | |
| from src.similarity.similarity import Similarity | |
| similarity = Similarity() | |
| models = similarity.get_models() | |
| def check(img_main, img_1, img_2, img_3, img_4, img_5, img_6, img_7, img_8, img_9, img_10): | |
| result = similarity.check_similarity([img_main, img_1, img_2, img_3, img_4, img_5, img_6, img_7, img_8, img_9, img_10], models[2]) | |
| return result | |
| with gr.Blocks() as demo: | |
| gr.Markdown('Checking Image Similarity') | |
| img_main = gr.Text(label='Main Image', placeholder='https://myimage.jpg') | |
| gr.Markdown('Images to check') | |
| # img_list = [] | |
| # for i in range(10): | |
| # img_list.append(gr.Text(label='{} st Image'.format(i), placeholder='https://myimage_1.jpg', i)) | |
| img_1 = gr.Text(label='1st Image', placeholder='https://myimage_1.jpg') | |
| print("img1: ", img_1) | |
| img_2 = gr.Text(label='2nd Image', placeholder='https://myimage_2.jpg') | |
| img_3 = gr.Text(label='3st Image', placeholder='https://myimage_1.jpg') | |
| img_4 = gr.Text(label='4nd Image', placeholder='https://myimage_2.jpg') | |
| img_5 = gr.Text(label='5st Image', placeholder='https://myimage_1.jpg') | |
| img_6 = gr.Text(label='6nd Image', placeholder='https://myimage_2.jpg') | |
| img_7 = gr.Text(label='7st Image', placeholder='https://myimage_1.jpg') | |
| img_8 = gr.Text(label='8nd Image', placeholder='https://myimage_2.jpg') | |
| img_9 = gr.Text(label='9st Image', placeholder='https://myimage_1.jpg') | |
| img_10 = gr.Text(label='10st Image', placeholder='https://myimage_2.jpg') | |
| # img_list = [img_1, img_2, img_3, img_4, img_5, img_6, img_7, img_8, img_9, img_10] | |
| # for i in range(len(img_list)): | |
| # img | |
| # gr.Markdown('Choose the model') | |
| # model = gr.Dropdown([m.name for m in models], label='Model', type='index') | |
| # print("model name:", model) | |
| gallery = gr.Gallery( | |
| label="Generated images", show_label=False, elem_id="gallery" | |
| ).style(grid=[10], height="auto") | |
| output_metric = gr.Text(label='output metrics') | |
| submit_btn = gr.Button('Check Similarity') | |
| submit_btn.click(fn=check,inputs=[img_main, img_1, img_2, img_3, img_4, img_5, img_6, img_7, img_8, img_9, img_10], outputs=gallery, api_name="predict") | |
| demo.launch() |