Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
from bs4 import BeautifulSoup
|
| 4 |
from google_img_source_search import ReverseImageSearcher
|
| 5 |
-
from PIL import
|
| 6 |
|
| 7 |
import os
|
| 8 |
import uuid
|
|
@@ -15,8 +15,6 @@ size_js="""
|
|
| 15 |
alert("Original width=" + realWidth + ", " + "Original height=" + realHeight);
|
| 16 |
}"""
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
def process_files(file):
|
| 21 |
read_file = Image.open(file)
|
| 22 |
read_file.save(f"{uid}-tmp.png")
|
|
@@ -25,8 +23,6 @@ def process_files(file):
|
|
| 25 |
out_url = f'https://omnibus-reverse-image.hf.space/file={out}'
|
| 26 |
return (out_url)
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
def rev_im(image_url):
|
| 31 |
#image_url = 'https://i.pinimg.com/originals/c4/50/35/c450352ac6ea8645ead206721673e8fb.png'
|
| 32 |
out_list = []
|
|
@@ -49,10 +45,7 @@ def rev_im(image_url):
|
|
| 49 |
Site: <a href='{search_item.page_url}' target='_blank' rel='noopener noreferrer'>{search_item.page_url}</a><br>
|
| 50 |
Img: <a href='{search_item.image_url}' target='_blank' rel='noopener noreferrer'>{search_item.image_url}</a><br>
|
| 51 |
<img class='my_im' src='{search_item.image_url}'><br>
|
| 52 |
-
|
| 53 |
</div>"""
|
| 54 |
-
|
| 55 |
-
|
| 56 |
return (gr.HTML(f'<h1>Total Found: {count}</h1><br>{html_out}'))
|
| 57 |
|
| 58 |
def find_it(inp):
|
|
@@ -78,9 +71,6 @@ def find_it(inp):
|
|
| 78 |
#https://lens.google.com/uploadbyurl?url=
|
| 79 |
#https://tineye.com/search/?url=
|
| 80 |
#https://yandex.com/images/search?cbir_id=4330355%2FBhPd4CHqib3nxk9xOdS9pQ7899&rpt=imageview&url=
|
| 81 |
-
def p_clip():
|
| 82 |
-
img = ImageGrab.grabclipboard()
|
| 83 |
-
return img
|
| 84 |
|
| 85 |
with gr.Blocks() as app:
|
| 86 |
with gr.Row():
|
|
@@ -90,11 +80,11 @@ with gr.Blocks() as app:
|
|
| 90 |
|
| 91 |
with gr.Column():
|
| 92 |
inp_im=gr.Image(type='filepath')
|
| 93 |
-
paste_clip = gr.Button("Paste from Clipboard")
|
| 94 |
with gr.Row():
|
| 95 |
|
| 96 |
html_out = gr.HTML("""""")
|
| 97 |
-
paste_clip.click(p_clip,None,inp_im)
|
| 98 |
inp_im.change(process_files,inp_im,[inp_url])
|
| 99 |
go_btn.click(rev_im,inp_url,[html_out])
|
| 100 |
app.launch()
|
|
|
|
| 2 |
import requests
|
| 3 |
from bs4 import BeautifulSoup
|
| 4 |
from google_img_source_search import ReverseImageSearcher
|
| 5 |
+
from PIL import Image
|
| 6 |
|
| 7 |
import os
|
| 8 |
import uuid
|
|
|
|
| 15 |
alert("Original width=" + realWidth + ", " + "Original height=" + realHeight);
|
| 16 |
}"""
|
| 17 |
|
|
|
|
|
|
|
| 18 |
def process_files(file):
|
| 19 |
read_file = Image.open(file)
|
| 20 |
read_file.save(f"{uid}-tmp.png")
|
|
|
|
| 23 |
out_url = f'https://omnibus-reverse-image.hf.space/file={out}'
|
| 24 |
return (out_url)
|
| 25 |
|
|
|
|
|
|
|
| 26 |
def rev_im(image_url):
|
| 27 |
#image_url = 'https://i.pinimg.com/originals/c4/50/35/c450352ac6ea8645ead206721673e8fb.png'
|
| 28 |
out_list = []
|
|
|
|
| 45 |
Site: <a href='{search_item.page_url}' target='_blank' rel='noopener noreferrer'>{search_item.page_url}</a><br>
|
| 46 |
Img: <a href='{search_item.image_url}' target='_blank' rel='noopener noreferrer'>{search_item.image_url}</a><br>
|
| 47 |
<img class='my_im' src='{search_item.image_url}'><br>
|
|
|
|
| 48 |
</div>"""
|
|
|
|
|
|
|
| 49 |
return (gr.HTML(f'<h1>Total Found: {count}</h1><br>{html_out}'))
|
| 50 |
|
| 51 |
def find_it(inp):
|
|
|
|
| 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():
|
|
|
|
| 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 |
+
#paste_clip.click(p_clip,None,inp_im)
|
| 88 |
inp_im.change(process_files,inp_im,[inp_url])
|
| 89 |
go_btn.click(rev_im,inp_url,[html_out])
|
| 90 |
app.launch()
|