Omnibus commited on
Commit
458c1fb
1 Parent(s): ee7d6a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -6
app.py CHANGED
@@ -4,17 +4,25 @@ from bs4 import BeautifulSoup
4
  from google_img_source_search import ReverseImageSearcher
5
 
6
 
7
- def rev_im(url):
8
- image_url = 'https://i.pinimg.com/originals/c4/50/35/c450352ac6ea8645ead206721673e8fb.png'
9
-
 
10
  rev_img_searcher = ReverseImageSearcher()
11
  res = rev_img_searcher.search(image_url)
12
 
13
  for search_item in res:
 
 
 
 
 
 
 
14
  print(f'Title: {search_item.page_title}')
15
  print(f'Site: {search_item.page_url}')
16
  print(f'Img: {search_item.image_url}\n')
17
- return search_item.image_url
18
 
19
  def find_it(inp):
20
  out=""
@@ -49,7 +57,11 @@ with gr.Blocks() as app:
49
  with gr.Column():
50
  inp_url=gr.Textbox(label="Image URL")
51
  go_btn=gr.Button()
 
52
  inp_im=gr.Image()
53
- outp_text = gr.Textbox(lines=4)
54
- go_btn.click(rev_im,inp_url,outp_text)
 
 
 
55
  app.launch()
 
4
  from google_img_source_search import ReverseImageSearcher
5
 
6
 
7
+ def rev_im(image_url):
8
+ #image_url = 'https://i.pinimg.com/originals/c4/50/35/c450352ac6ea8645ead206721673e8fb.png'
9
+ out_list = []
10
+ out_im = []
11
  rev_img_searcher = ReverseImageSearcher()
12
  res = rev_img_searcher.search(image_url)
13
 
14
  for search_item in res:
15
+ out_dict={
16
+ 'Title': f'{search_item.page_title}',
17
+ 'Site': f'{search_item.page_url}',
18
+ 'Img': f'{search_item.image_url}',
19
+ }
20
+ out_list.append(out_dict)
21
+ out_im.append(search_item.image_url)
22
  print(f'Title: {search_item.page_title}')
23
  print(f'Site: {search_item.page_url}')
24
  print(f'Img: {search_item.image_url}\n')
25
+ return out_list,out_im
26
 
27
  def find_it(inp):
28
  out=""
 
57
  with gr.Column():
58
  inp_url=gr.Textbox(label="Image URL")
59
  go_btn=gr.Button()
60
+
61
  inp_im=gr.Image()
62
+ with gr.Row():
63
+
64
+ outp_text = gr.Textbox(lines=4)
65
+ outg = gr.Gallery()
66
+ go_btn.click(rev_im,inp_url,[outp_text,outg])
67
  app.launch()