|
import gradio as gr |
|
import os |
|
from main_infer import INFER_API |
|
|
|
|
|
def process_image(image): |
|
|
|
save_path = os.path.join(os.getcwd(), "images") |
|
|
|
os.makedirs(save_path, exist_ok=True) |
|
|
|
|
|
from datetime import datetime |
|
timestamp = datetime.now().strftime("%Y%m%d%H%M%S") |
|
image_filename = f"uploaded_{timestamp}.png" |
|
image_path = os.path.join(save_path, image_filename) |
|
|
|
|
|
image.save(image_path) |
|
infer_api = INFER_API() |
|
score = infer_api.test(image_path) |
|
|
|
return score |
|
|
|
|
|
image_input = gr.components.Image(label="Upload Image", type="pil") |
|
|
|
|
|
text_output = gr.components.Textbox() |
|
|
|
|
|
demo = gr.Interface(fn=process_image, inputs=image_input, outputs=text_output, live=False) |
|
|
|
|
|
demo.launch() |
|
|