from turtle import ht import requests import gradio as gr def make_request(img_url, min_score): headers = { 'accept': 'application/json', 'public-key': 'xxx', } params = { 'url': img_url, 'min_score': min_score, } response = requests.get('https://api-similarity-zx53qegsda-as.a.run.app/v1/similarity/', params=params, headers=headers) result = response.json() return result def show_result(image_url, min_score=0.7): result = make_request(image_url, min_score) html = f'Original Image

' if len(result['result']) == 0: html += '

No Similar Photo Found

' else: html += f'

{len(result["result"])} Photos Found




' html += '' for i, raw in enumerate(result['result']): detail = raw["detail"] html += f''' ''' if i > 0 and i%2 == 1: html += '' html += "

{raw["similarity"] * 100}%

Title: {detail["title"]}

User : {detail["user"]["name"]}


" return (html) demo = gr.Interface(fn=show_result, inputs=["text","text"], outputs=["html"]) demo.launch(debug=False)