Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Define a function that takes an image as input and uses the model for inference
|
2 |
def image_classifier(image):
|
3 |
# Preprocess the input image
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from tensorflow import keras
|
3 |
+
import numpy as np
|
4 |
+
from huggingface_hub import HfFileSystem
|
5 |
+
from PIL import Image
|
6 |
+
|
7 |
+
# Authenticate and download the custom model from Hugging Face Spaces
|
8 |
+
fs = HfFileSystem()
|
9 |
+
model_path = 'dhhd255/main_model/best_model.h5'
|
10 |
+
with fs.open(model_path, 'rb') as f:
|
11 |
+
model_content = f.read()
|
12 |
+
|
13 |
+
# Save the model file to disk
|
14 |
+
with open('best_model.h5', 'wb') as f:
|
15 |
+
f.write(model_content)
|
16 |
+
|
17 |
+
# Load your custom model
|
18 |
+
model = keras.models.load_model('best_model.h5')
|
19 |
+
|
20 |
# Define a function that takes an image as input and uses the model for inference
|
21 |
def image_classifier(image):
|
22 |
# Preprocess the input image
|