| |
| """app creation.ipynb |
| |
| Automatically generated by Colaboratory. |
| |
| Original file is located at |
| https://colab.research.google.com/drive/1c8HIdMTAJxhNiPY7_kmzP78yFiwdhh8Q |
| """ |
|
|
| import gradio as gr |
| from fastai import * |
| from fastai.vision.all import * |
|
|
| |
| |
| |
|
|
| model = load_learner("models/recgonizer_model.pkl") |
|
|
| labels = ['Ayre', 'Catla', 'Chital', 'Ilish', 'Kachki', 'Kajoli', 'Koi', 'Magur', 'Mola Dhela', 'Mrigal', 'Pabda', 'Pangash', 'Poa', 'Puti', 'Rui', 'Shing', 'Silver Carp', 'Taki', 'Telapia', 'Tengra'] |
|
|
| def recognize_image(image_path): |
| label, _, probs = model.predict(image_path) |
| return dict(zip(labels, map(float, probs))) |
|
|
| inputs = gr.Image(height=512, width=512) |
| outputs = gr.Label() |
|
|
| examples = [ |
| 'test images/unknown_01.jpg', |
| 'test images/unknown_02.png', |
| 'test images/unknown_03.jpg', |
| 'test images/unknown_04.jpg', |
| 'test images/unknown_05.jpg', |
| 'test images/unknown_06.jpg', |
| 'test images/unknown_07.jpg', |
| 'test images/unknown_08.jpg', |
| 'test images/unknown_09.jpg', |
| 'test images/unknown_10.jpg', |
| 'test images/unknown_11.jpg', |
| 'test images/unknown_12.png', |
| 'test images/unknown_13.jpg', |
| 'test images/unknown_14.png', |
| 'test images/unknown_15.png', |
| 'test images/unknown_16.png', |
| 'test images/unknown_17.jpg' |
| ] |
|
|
| interface = gr.Interface(fn=recognize_image, inputs = inputs, outputs=outputs, examples = examples) |
|
|
| interface.launch(debug=True, share=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|