import numpy as np import gradio as gr from roboflow import Roboflow from PIL import Image def obj(input_img): #load model rf = Roboflow(api_key="u5HA4Ou9LROqjjWJYSJV") project = rf.workspace("modzie-work").project("bmd-result") model = project.version(1).model #save to .jpg img = Image.fromarray(input_img, "RGB") img.save("image_filename.jpg") image_save_test = 'image_filename.jpg' #predict obj_result = model.predict(image_save_test, confidence=40, overlap=30).json()['predictions'][0]['class'] if obj_result == "Low Bone": obj_result = "Osteopenia" return obj_result demo = gr.Interface(obj, "image", "text") demo.launch()