MeghanaM4 commited on
Commit
86edadb
·
verified ·
1 Parent(s): 16bb8ee

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # %% [code] {"execution":{"iopub.status.busy":"2024-11-09T18:30:07.510515Z","iopub.execute_input":"2024-11-09T18:30:07.513741Z","iopub.status.idle":"2024-11-09T18:30:08.913485Z","shell.execute_reply.started":"2024-11-09T18:30:07.513509Z","shell.execute_reply":"2024-11-09T18:30:08.912208Z"}}
2
+ # This Python 3 environment comes with many helpful analytics libraries installed
3
+ # It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
4
+ # For example, here's several helpful packages to load
5
+
6
+ import numpy as np # linear algebra
7
+ import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
8
+
9
+ # Input data files are available in the read-only "../input/" directory
10
+ # For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory
11
+
12
+ import os
13
+ for dirname, _, filenames in os.walk('/kaggle/input'):
14
+ for filename in filenames:
15
+ print(os.path.join(dirname, filename))
16
+
17
+ from fastai.vision.all import *
18
+ !pip install gradio
19
+ import gradio as gr
20
+
21
+ share = True
22
+
23
+ learn = load_learner('/kaggle/input/wastedetective/pytorch/default/1/model.pkl')
24
+
25
+ categories = ('Batteries', 'Organic Matter', 'Primary', 'Tertiary')
26
+
27
+ def classify_image(img):
28
+ pred,idx,probs = learn.predict(img)
29
+ return dict(zip(categories, map(float, probs)))
30
+
31
+ image = "image"
32
+ label = "label"
33
+
34
+ intf = gr.Interface(fn=classify_image, inputs = image, outputs = label)
35
+ intf.launch(inline = False, share = True)