Omnibus commited on
Commit
e8f283e
1 Parent(s): 522ecb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -18
app.py CHANGED
@@ -4,7 +4,8 @@ from bs4 import BeautifulSoup
4
  from google_img_source_search import ReverseImageSearcher
5
  from PIL import Image
6
  import os
7
-
 
8
  size_js="""
9
  function imgSize(){
10
  var myImg = document.getElementsByClassName("my_im");
@@ -17,22 +18,11 @@ size_js="""
17
 
18
  def process_files(file):
19
  read_file = Image.open(file)
20
- read_file.save("tmp.png")
21
- action_input = "Passed"
22
- try:
23
- action_input=f"{file.name}"
24
- print ("first")
25
- except Exception as e:
26
- print (e)
27
- try:
28
- action_input = "tmp.png"
29
- print ("Second")
30
- except Exception as e:
31
- print (e)
32
- print(os.path.abspath(action_input))
33
  out = os.path.abspath(action_input)
34
-
35
- return ("tmp.png",out)
36
 
37
 
38
 
@@ -94,11 +84,10 @@ with gr.Blocks() as app:
94
  with gr.Column():
95
  inp_url=gr.Textbox(label="Image URL")
96
  go_btn=gr.Button()
97
- out_file=gr.File()
98
  inp_im=gr.Image(type='filepath')
99
  with gr.Row():
100
 
101
  html_out = gr.HTML("""""")
102
- inp_im.change(process_files,inp_im,[out_file,inp_url])
103
  go_btn.click(rev_im,inp_url,[html_out])
104
  app.launch()
 
4
  from google_img_source_search import ReverseImageSearcher
5
  from PIL import Image
6
  import os
7
+ import uuid
8
+ uid=uuid.uuid4()
9
  size_js="""
10
  function imgSize(){
11
  var myImg = document.getElementsByClassName("my_im");
 
18
 
19
  def process_files(file):
20
  read_file = Image.open(file)
21
+ read_file.save(f"{uid}-tmp.png")
22
+ action_input = f"{uid}-tmp.png"
 
 
 
 
 
 
 
 
 
 
 
23
  out = os.path.abspath(action_input)
24
+ out_url = f'https://omnibus-reverse-image.hf.space/file={out}'
25
+ return (out_url)
26
 
27
 
28
 
 
84
  with gr.Column():
85
  inp_url=gr.Textbox(label="Image URL")
86
  go_btn=gr.Button()
 
87
  inp_im=gr.Image(type='filepath')
88
  with gr.Row():
89
 
90
  html_out = gr.HTML("""""")
91
+ inp_im.change(process_files,inp_im,[inp_url])
92
  go_btn.click(rev_im,inp_url,[html_out])
93
  app.launch()