import gradio as gr import requests from bs4 import BeautifulSoup from google_img_source_search import ReverseImageSearcher from PIL import Image import os import uuid uid=uuid.uuid4() size_js=""" function imgSize(){ var myImg = document.getElementsByClassName("my_im"); var realWidth = myImg.naturalWidth; var realHeight = myImg.naturalHeight; alert("Original width=" + realWidth + ", " + "Original height=" + realHeight); }""" def process_files(file): read_file = Image.open(file) read_file.save(f"{uid}-tmp.png") action_input = f"{uid}-tmp.png" out = os.path.abspath(action_input) out_url = f'https://omnibus-reverse-image.hf.space/file={out}' return (out_url) def rev_im(image_url): #image_url = 'https://i.pinimg.com/originals/c4/50/35/c450352ac6ea8645ead206721673e8fb.png' out_list = [] out_im = [] html_out = """""" rev_img_searcher = ReverseImageSearcher() res = rev_img_searcher.search(image_url) count = 0 for search_item in res: count+=1 out_dict={ 'Title': f'{search_item.page_title}', 'Site': f'{search_item.page_url}', 'Img': f'{search_item.image_url}', } print (dir(search_item)) html_out = f"""{html_out}
""" return (gr.HTML(f'