File size: 975 Bytes
2c5cec5
dfbae18
 
0953fe9
1dc0fbb
dfbae18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import streamlit as st
import torch
from transformers import pipeline
from PIL import Image
import os
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

# Load Hugging Face model
model_url = os.getenv('HUGGINGFACE_MODEL_URL')
model = torch.hub.load(model_url, 'model', source='hf')

# Setup Streamlit
st.title('Yellow Rust Severity Prediction')

# File uploader
uploaded_file = st.file_uploader("Upload an image of Yellow Rust", type=["jpg", "png"])

if uploaded_file is not None:
    # Display the uploaded image
    image = Image.open(uploaded_file)
    st.image(image, caption="Uploaded Image", use_column_width=True)
    
    # Process the image and make prediction
    classifier = pipeline('image-classification', model=model_url)
    results = classifier(image)
    
    severity_level = results[0]['label']
    confidence = results[0]['score']
    
    st.write(f"Predicted Severity Level: {severity_level} with confidence: {confidence:.2f}")