Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import tensorflow as tf
|
| 3 |
-
from PIL import Image
|
| 4 |
-
import numpy as np
|
| 5 |
-
|
| 6 |
-
# Lade das Modell
|
| 7 |
-
model = tf.keras.models.load_model("fruit_classifier_model.keras")
|
| 8 |
-
|
| 9 |
-
class_names = ['Apple', 'Banana', 'Grapes', 'Kiwi', 'Orange', 'Pineapple', 'Strawberries']
|
| 10 |
-
|
| 11 |
-
def classify_fruit(image):
|
| 12 |
-
image = Image.fromarray(image).resize((224, 224))
|
| 13 |
-
image = np.array(image) / 255.0
|
| 14 |
-
image = np.expand_dims(image, axis=0)
|
| 15 |
-
predictions = model.predict(image)[0]
|
| 16 |
-
|
| 17 |
-
results = {class_name: float(predictions[i]) for i, class_name in enumerate(class_names)}
|
| 18 |
-
return results
|
| 19 |
-
|
| 20 |
-
interface = gr.Interface(
|
| 21 |
-
fn=classify_fruit,
|
| 22 |
-
inputs=gr.Image(),
|
| 23 |
-
outputs=gr.Label(num_top_classes=3),
|
| 24 |
-
live=True
|
| 25 |
-
)
|
| 26 |
-
|
| 27 |
-
if __name__ == "__main__":
|
| 28 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|