import gradio as gr import os from utils import switch_case_dict, get_adapter, saveImg SAVE_DIR = "uploads" if not os.path.exists(SAVE_DIR): os.makedirs(SAVE_DIR) def process_image(imageUrl, module='sequential'): print(imageUrl) try: saveImg(SAVE_DIR, imageUrl) adapter_name = switch_case_dict(module) adapter = get_adapter(adapter_name) prediction = adapter.predict() return prediction except Exception as e: print(e) demo = gr.Interface( fn=process_image, # Function to process the image inputs=gr.Text(label="Enter Image URL"), # Accept a URL as text input outputs=[gr.Textbox()], # Return text and processed image title="Image URL Processor", description="Enter an image URL, and I'll process it!" ) process_image('https://firebasestorage.googleapis.com/v0/b/poultry-shield.appspot.com/o/cocci_15.jpg?alt=media&token=5a622f53-370b-4105-84a0-0338600fae4b') demo.launch()