Spaces:
Runtime error
Runtime error
nurindahpratiwi
commited on
Commit
•
eb59d5e
1
Parent(s):
ed5674e
update code line
Browse files
app.py
CHANGED
@@ -3,26 +3,24 @@ import streamlit as st
|
|
3 |
from transformers import pipeline
|
4 |
from PIL import Image
|
5 |
|
6 |
-
|
7 |
-
Model yang digunakan, merupakan model leaf disease yang telah ditentukan/dicari dari huggingface
|
8 |
-
'''
|
9 |
|
10 |
-
pipeline = pipeline(task=
|
11 |
|
12 |
-
# Buat judul
|
13 |
st.title("Leaf Disease Detection")
|
14 |
|
15 |
-
# Buat button yang meminta user menggunggah
|
16 |
file_name = st.file_uploader("Upload a leaf candidate image")
|
17 |
|
18 |
-
# Cek apakah
|
19 |
if file_name is not None:
|
20 |
-
col1, col2 = st.columns(2) #
|
21 |
|
22 |
-
image = Image.open(file_name) #
|
23 |
col1.image(image, use_column_width=True) # Menampilkan image di kolom 1
|
24 |
-
predictions = pipeline(image) #
|
25 |
|
26 |
-
col2.header("Confidence score") #
|
27 |
-
for p in predictions:
|
28 |
-
col2.subheader(f"{p['label']}: {round(p['score']*100,1)}%") #
|
|
|
3 |
from transformers import pipeline
|
4 |
from PIL import Image
|
5 |
|
6 |
+
#Buat variabel pipeline berisi fungsi pipeline dari lib transformers
|
|
|
|
|
7 |
|
8 |
+
pipeline = pipeline(task="image-classification", model="Bazaar/cv_apple_leaf_disease_detection")
|
9 |
|
10 |
+
# Buat judul menggunakan st.title
|
11 |
st.title("Leaf Disease Detection")
|
12 |
|
13 |
+
# Buat button yang meminta user menggunggah sebuah image daun
|
14 |
file_name = st.file_uploader("Upload a leaf candidate image")
|
15 |
|
16 |
+
# Cek apakah file name tidak None, jika True jalankan perintah selanjutnya
|
17 |
if file_name is not None:
|
18 |
+
col1, col2 = st.columns(2) # terdapat 2 kolom
|
19 |
|
20 |
+
image = Image.open(file_name) # Fungsi untuk membuka image file
|
21 |
col1.image(image, use_column_width=True) # Menampilkan image di kolom 1
|
22 |
+
predictions = pipeline(image) # melakukan prediksi dari input image
|
23 |
|
24 |
+
col2.header("Confidence score") # menampilkan judul di kolom 2
|
25 |
+
for p in predictions: # menampilkan angka confidence score
|
26 |
+
col2.subheader(f"{p['label']}: {round(p['score']*100, 1)}%") #menampilkan confidence score dalam satuan persen
|