import gradio as gr from fastai.vision.all import * from fastcore.all import * learn = load_learner("model1.pkl") categories = ('Simmental','Holstein',"Hereford","Angus","Charolais","Limousin","Jersey","Brown Swiss") def classify_img(img): pred,idx,probs = learn.predict(img) return dict(zip(categories, map(float,probs))) with gr.Blocks(title = "ineğin türü nedir? ") as demo: with gr.Row(): gr.Markdown(""" ## inek türü Tespiti #### Bilgisayarınızdan yada telefonunuzdan resim yükleyin #### Denemek amaçlı örneklere çift tıklayın ve Tahmin Et tuşuna basın """) with gr.Row(): image = gr.inputs.Image(shape=(192,192)) with gr.Row(): output = gr.outputs.Label() with gr.Row(): image_button = gr.Button("Tahmin Et") image_button.click(classify_img, inputs=image, outputs=output) with gr.Row(): with gr.Column(): gr.Examples(inputs=image,examples=["1.jpg"],label="angus") with gr.Column(): gr.Examples(inputs=image,examples=["2.jpg"],label="jersey") with gr.Column(): gr.Examples(inputs=image,examples=["3.jpg"],label="simmental") demo.launch()