mohamed abdallah mohamed shehab
commited on
Commit
·
c9c48e8
1
Parent(s):
1355cff
app production
Browse files- app.py +33 -0
- model.pkl +3 -0
- monkeypox.ipynb +0 -0
- requirements.txt +6 -0
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import joblib
|
| 5 |
+
|
| 6 |
+
# Load the trained model
|
| 7 |
+
model = joblib.load("model.pkl")
|
| 8 |
+
|
| 9 |
+
# Define class labels (غير الأسامي دي حسب الكلاسات اللي عندك بالضبط)
|
| 10 |
+
class_names = ["Not Monkeypox", "Monkeypox"]
|
| 11 |
+
|
| 12 |
+
def predict(img):
|
| 13 |
+
# Resize image to match model input size
|
| 14 |
+
img = img.resize((224,224))
|
| 15 |
+
img = np.array(img) / 255.0 # normalize
|
| 16 |
+
img = np.expand_dims(img, axis=0)
|
| 17 |
+
|
| 18 |
+
# Predict
|
| 19 |
+
preds = model.predict(img)
|
| 20 |
+
|
| 21 |
+
# Convert predictions to dictionary
|
| 22 |
+
return {class_names[i]: float(preds[0][i]) for i in range(len(class_names))}
|
| 23 |
+
|
| 24 |
+
demo = gr.Interface(
|
| 25 |
+
fn=predict,
|
| 26 |
+
inputs=gr.Image(type="pil"),
|
| 27 |
+
outputs=gr.Label(num_top_classes=2),
|
| 28 |
+
title="Monkeypox Classifier",
|
| 29 |
+
description="Upload an image and the model will classify it as Monkeypox or Not."
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
demo.launch()
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:230ac62ec49f907be731124dd76cba9ae0b777e9fa0744c62e5adcf7383ab30d
|
| 3 |
+
size 265147396
|
monkeypox.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
numpy
|
| 3 |
+
pillow
|
| 4 |
+
tensorflow
|
| 5 |
+
scikit-learn
|
| 6 |
+
joblib
|