Adonai Vera commited on
Commit
a5df04e
1 Parent(s): 40fb715

App ready to test on production

Browse files
.DS_Store ADDED
Binary file (6.15 kB). View file
 
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from turtle import title
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+ from PIL import Image
5
+
6
+ # Initialize the pipeline with your model
7
+ pipe = pipeline("image-classification", model="adonaivera/ofwat_material_classification")
8
+
9
+ def classify_image(image):
10
+ # Convert the input image to PIL format
11
+ PIL_image = Image.fromarray(image).convert('RGB')
12
+
13
+ # Classify the image using the pipeline
14
+ res = pipe(PIL_image)
15
+
16
+ # Extract labels and scores
17
+ return {dic["label"]: dic["score"] for dic in res}
18
+
19
+ # Create the Gradio interface
20
+ iface = gr.Interface(
21
+ classify_image,
22
+ "image",
23
+ "label",
24
+ examples=[
25
+ ["examples/CS.jpg"],
26
+ ["examples/GI.jpg"],
27
+ ["examples/PP.jpg"],
28
+ ["examples/RC.jpg"]
29
+ ],
30
+ description="Upload an image to classify its material.",
31
+ title="Material Classification with AI by Subterra"
32
+ )
33
+
34
+ # Launch the interface
35
+ iface.launch()
examples/.DS_Store ADDED
Binary file (6.15 kB). View file
 
examples/CS.jpg ADDED
examples/GI.jpg ADDED
examples/PP.jpg ADDED
examples/RC.jpg ADDED
flagged/image/d97b9ae054eab1bd10dc/PP.jpg ADDED
flagged/log.csv ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ image,output 0,output 1,flag,username,timestamp
2
+ "{""path"":""flagged/image/d97b9ae054eab1bd10dc/PP.jpg"",""url"":""http://127.0.0.1:7860/file=/private/var/folders/5q/yl8pmxm116g6r3k8fd9gk74m0000gn/T/gradio/12885a897d79141c54ccb542582449159242eaa0/PP.jpg"",""size"":null,""orig_name"":""PP.jpg"",""mime_type"":null}","{""label"":""VC"",""confidences"":[{""label"":""VC"",""confidence"":0.7706952691078186},{""label"":""PVC"",""confidence"":0.20648105442523956},{""label"":""PE"",""confidence"":0.005161861423403025},{""label"":""PF"",""confidence"":0.004196972120553255},{""label"":""CO"",""confidence"":0.0034184197429567575}]}","| Prefix | Full Name |
3
+ | ------ | --------- |
4
+ | CS | Carbon Steel |
5
+ | GI | Galvanized Iron |
6
+ | PP | Polypropylene |
7
+ | RC | Reinforced Concrete |",,,2023-11-27 15:26:38.548865