Spaces:
Sleeping
Sleeping
File size: 875 Bytes
000a6ec 7f6a958 000a6ec 8efa25e 000a6ec 7f6a958 000a6ec 7f2faca |
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 31 32 33 |
import json
import gradio as gr
import yolov5
model = yolov5.load('model/Cinderella.pt')
#てすと
def inference(gr_input):
with open("json/idol_classes.json", "r")as f:
dic = json.load(f)
predictions = model(gr_input).pred[0]
name = [x for x in dic.values()]
idols = []
for i in predictions[:, 5]: # 検出
idols.append(name[int(i.item())])
if len(idols) == 0:
return "該当するクラスが存在しません"
else:
text = "\n".join(idols)
return text
with gr.Blocks() as app:
inputs = gr.inputs.Image()
output = gr.Textbox()
gr.Markdown(
"# <center> デレマス画像分類器\n"
"## <center> シンデレラガールズのキャラの画像を貼ると、機械学習で判別できるモデルです\n"
)
inputs.change(inference, inputs, out)
demo.launch()
|