Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
-
from bs4 import BeautifulSoup
|
|
|
4 |
from google_img_source_search import ReverseImageSearcher
|
5 |
from PIL import Image
|
6 |
|
@@ -15,7 +16,16 @@ size_js="""
|
|
15 |
alert("Original width=" + realWidth + ", " + "Original height=" + realHeight);
|
16 |
}"""
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
read_file = Image.open(file)
|
20 |
read_file.save(f"{uid}-tmp.png")
|
21 |
action_input = f"{uid}-tmp.png"
|
@@ -48,43 +58,37 @@ def rev_im(image_url):
|
|
48 |
</div>"""
|
49 |
return (gr.HTML(f'<h1>Total Found: {count}</h1><br>{html_out}'))
|
50 |
|
51 |
-
def
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
soup = BeautifulSoup(page_content, "html.parser")
|
62 |
-
print(soup.prettify())
|
63 |
-
articles = soup.find_all("article")
|
64 |
-
out = soup.prettify
|
65 |
-
print (articles)
|
66 |
-
|
67 |
-
except Exception as e:
|
68 |
-
out = e
|
69 |
-
print (e)
|
70 |
-
return (out)
|
71 |
-
#https://lens.google.com/uploadbyurl?url=
|
72 |
-
#https://tineye.com/search/?url=
|
73 |
-
#https://yandex.com/images/search?cbir_id=4330355%2FBhPd4CHqib3nxk9xOdS9pQ7899&rpt=imageview&url=
|
74 |
|
75 |
with gr.Blocks() as app:
|
76 |
with gr.Row():
|
|
|
77 |
with gr.Column():
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
go_btn=gr.Button()
|
80 |
-
|
81 |
-
with gr.Column():
|
82 |
-
inp_im=gr.Image(type='filepath')
|
83 |
#paste_clip = gr.Button("Paste from Clipboard")
|
84 |
with gr.Row():
|
85 |
|
86 |
html_out = gr.HTML("""""")
|
87 |
-
|
88 |
inp_im.change(process_files,inp_im,[inp_url])
|
|
|
|
|
89 |
go_btn.click(rev_im,inp_url,[html_out])
|
90 |
app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
+
#from bs4 import BeautifulSoup
|
4 |
+
import cv2
|
5 |
from google_img_source_search import ReverseImageSearcher
|
6 |
from PIL import Image
|
7 |
|
|
|
16 |
alert("Original width=" + realWidth + ", " + "Original height=" + realHeight);
|
17 |
}"""
|
18 |
|
19 |
+
|
20 |
+
def process_vid(file):
|
21 |
+
read_file = Image.open(file)
|
22 |
+
read_file.save(f"{uid}-tmp.png")
|
23 |
+
action_input = f"{uid}-tmp.png"
|
24 |
+
out = os.path.abspath(action_input)
|
25 |
+
out_url = f'https://omnibus-reverse-image.hf.space/file={out}'
|
26 |
+
return (out_url)
|
27 |
+
|
28 |
+
def process_im(file):
|
29 |
read_file = Image.open(file)
|
30 |
read_file.save(f"{uid}-tmp.png")
|
31 |
action_input = f"{uid}-tmp.png"
|
|
|
58 |
</div>"""
|
59 |
return (gr.HTML(f'<h1>Total Found: {count}</h1><br>{html_out}'))
|
60 |
|
61 |
+
def shuf(tog):
|
62 |
+
if tog == "URL":
|
63 |
+
return gr.update(visible=True),gr.update(visible=False),gr.update(visible=False)
|
64 |
+
if tog == "Image":
|
65 |
+
return gr.update(visible=False),gr.update(visible=True),gr.update(visible=False)
|
66 |
+
if tog == "Video":
|
67 |
+
return gr.update(visible=False),gr.update(visible=False),gr.update(visible=True)
|
68 |
+
|
69 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
with gr.Blocks() as app:
|
72 |
with gr.Row():
|
73 |
+
gr.Column()
|
74 |
with gr.Column():
|
75 |
+
|
76 |
+
source_tog=gr.Radio(choices=["URL","Image","Video"],value="URL")
|
77 |
+
with gr.Box(visible=True) as url_box:
|
78 |
+
inp_url=gr.Textbox(label="Image URL")
|
79 |
+
with gr.Box(visible=False) as im_box:
|
80 |
+
inp_im=gr.Image(label="Search Image",type='filepath')
|
81 |
+
with gr.Box(visible=False) as vid_box:
|
82 |
+
inp_vid=gr.Video(label="Search Video",type='filepath')
|
83 |
go_btn=gr.Button()
|
84 |
+
gr.Column()
|
|
|
|
|
85 |
#paste_clip = gr.Button("Paste from Clipboard")
|
86 |
with gr.Row():
|
87 |
|
88 |
html_out = gr.HTML("""""")
|
89 |
+
source_tog.change(shuf,[source_tog],[url_box,im_box,inp_box])
|
90 |
inp_im.change(process_files,inp_im,[inp_url])
|
91 |
+
inp_vid.change(process_files,inp_vid,[inp_url])
|
92 |
+
|
93 |
go_btn.click(rev_im,inp_url,[html_out])
|
94 |
app.launch()
|