File size: 966 Bytes
2a83d46
6f20514
e380fb8
9fe6e2a
 
6f20514
 
7579546
9fe6e2a
9be18e3
 
 
 
 
 
 
 
 
9fe6e2a
7e05604
6f20514
b4a1288
9be18e3
b4a1288
 
5b3a7e4
9be18e3
7198984
2a83d46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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()