NarendraMall commited on
Commit
eb061b1
·
1 Parent(s): 868f784

updated app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -7
app.py CHANGED
@@ -7,8 +7,8 @@ from src.similarity.similarity import Similarity
7
  similarity = Similarity()
8
  models = similarity.get_models()
9
 
10
- def check(img_main, img_1, img_2, model_idx):
11
- result = similarity.check_similarity([img_main, img_1, img_2], models[model_idx])
12
  return result
13
 
14
  with gr.Blocks() as demo:
@@ -16,17 +16,35 @@ with gr.Blocks() as demo:
16
  img_main = gr.Text(label='Main Image', placeholder='https://myimage.jpg')
17
 
18
  gr.Markdown('Images to check')
 
 
 
19
  img_1 = gr.Text(label='1st Image', placeholder='https://myimage_1.jpg')
 
20
  img_2 = gr.Text(label='2nd Image', placeholder='https://myimage_2.jpg')
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- gr.Markdown('Choose the model')
23
- model = gr.Dropdown([m.name for m in models], label='Model', type='index')
 
24
 
25
  gallery = gr.Gallery(
26
  label="Generated images", show_label=False, elem_id="gallery"
27
- ).style(grid=[2], height="auto")
28
 
 
29
  submit_btn = gr.Button('Check Similarity')
30
- submit_btn.click(fn=check,inputs=[img_main, img_1, img_2, model], outputs=gallery)
31
 
32
- demo.launch()
 
7
  similarity = Similarity()
8
  models = similarity.get_models()
9
 
10
+ def check(img_main, img_1, img_2, img_3, img_4, img_5, img_6, img_7, img_8, img_9, img_10):
11
+ 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])
12
  return result
13
 
14
  with gr.Blocks() as demo:
 
16
  img_main = gr.Text(label='Main Image', placeholder='https://myimage.jpg')
17
 
18
  gr.Markdown('Images to check')
19
+ # img_list = []
20
+ # for i in range(10):
21
+ # img_list.append(gr.Text(label='{} st Image'.format(i), placeholder='https://myimage_1.jpg', i))
22
  img_1 = gr.Text(label='1st Image', placeholder='https://myimage_1.jpg')
23
+ print("img1: ", img_1)
24
  img_2 = gr.Text(label='2nd Image', placeholder='https://myimage_2.jpg')
25
+ img_3 = gr.Text(label='3st Image', placeholder='https://myimage_1.jpg')
26
+ img_4 = gr.Text(label='4nd Image', placeholder='https://myimage_2.jpg')
27
+ img_5 = gr.Text(label='5st Image', placeholder='https://myimage_1.jpg')
28
+ img_6 = gr.Text(label='6nd Image', placeholder='https://myimage_2.jpg')
29
+ img_7 = gr.Text(label='7st Image', placeholder='https://myimage_1.jpg')
30
+ img_8 = gr.Text(label='8nd Image', placeholder='https://myimage_2.jpg')
31
+ img_9 = gr.Text(label='9st Image', placeholder='https://myimage_1.jpg')
32
+ img_10 = gr.Text(label='10st Image', placeholder='https://myimage_2.jpg')
33
+
34
+ # img_list = [img_1, img_2, img_3, img_4, img_5, img_6, img_7, img_8, img_9, img_10]
35
+ # for i in range(len(img_list)):
36
+ # img
37
 
38
+ # gr.Markdown('Choose the model')
39
+ # model = gr.Dropdown([m.name for m in models], label='Model', type='index')
40
+ # print("model name:", model)
41
 
42
  gallery = gr.Gallery(
43
  label="Generated images", show_label=False, elem_id="gallery"
44
+ ).style(grid=[10], height="auto")
45
 
46
+ output_metric = gr.Text(label='output metrics')
47
  submit_btn = gr.Button('Check Similarity')
48
+ 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=output_metric, api_name="predict")
49
 
50
+ demo.launch(share=True)