Spaces:
Configuration error
Configuration error
Upload 3 files
Browse files- README.md +1 -12
- microguru.ipynb +52 -0
- microgurutestmodel.h5 +3 -0
README.md
CHANGED
|
@@ -1,12 +1 @@
|
|
| 1 |
-
|
| 2 |
-
title: Microbeguru
|
| 3 |
-
emoji: 💻
|
| 4 |
-
colorFrom: red
|
| 5 |
-
colorTo: green
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 4.28.3
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
-
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
# MicroGuru
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
microguru.ipynb
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": null,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [],
|
| 8 |
+
"source": [
|
| 9 |
+
"import gradio as gr\n",
|
| 10 |
+
"import tensorflow as tf\n",
|
| 11 |
+
"import numpy as np\n",
|
| 12 |
+
"\n",
|
| 13 |
+
"# Load the pre-trained model\n",
|
| 14 |
+
"model = tf.keras.models.load_model(\"\")\n",
|
| 15 |
+
"\n",
|
| 16 |
+
"# Define the prediction function\n",
|
| 17 |
+
"def classify_image(image):\n",
|
| 18 |
+
" # Preprocess the image\n",
|
| 19 |
+
" image = tf.image.resize(image, (224, 224))\n",
|
| 20 |
+
" image = tf.keras.applications.mobilenet_v2.preprocess_input(image)\n",
|
| 21 |
+
" image = np.expand_dims(image, axis=0)\n",
|
| 22 |
+
"\n",
|
| 23 |
+
" # Make predictions\n",
|
| 24 |
+
" predictions = model.predict(image)\n",
|
| 25 |
+
" label = np.argmax(predictions[0])\n",
|
| 26 |
+
" confidence = predictions[0][label]\n",
|
| 27 |
+
"\n",
|
| 28 |
+
" return label, confidence\n",
|
| 29 |
+
"\n",
|
| 30 |
+
"# Create the Gradio interface\n",
|
| 31 |
+
"inputs = gr.inputs.Image()\n",
|
| 32 |
+
"outputs = gr.outputs.Label(num_top_classes=3)\n",
|
| 33 |
+
"\n",
|
| 34 |
+
"# Launch the interface with a public link\n",
|
| 35 |
+
"gr.Interface(\n",
|
| 36 |
+
" fn=classify_image, \n",
|
| 37 |
+
" inputs=inputs, \n",
|
| 38 |
+
" outputs=outputs, \n",
|
| 39 |
+
" title=\"Micro-Guru\", \n",
|
| 40 |
+
" description=\"Upload an image and the model will predict its class along with the confidence level.\"\n",
|
| 41 |
+
").launch(share=True)"
|
| 42 |
+
]
|
| 43 |
+
}
|
| 44 |
+
],
|
| 45 |
+
"metadata": {
|
| 46 |
+
"language_info": {
|
| 47 |
+
"name": "python"
|
| 48 |
+
}
|
| 49 |
+
},
|
| 50 |
+
"nbformat": 4,
|
| 51 |
+
"nbformat_minor": 2
|
| 52 |
+
}
|
microgurutestmodel.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:231fa442d8b71c61d8809528d36fbfdd9fa31754b411a171b630c96150cca688
|
| 3 |
+
size 63687648
|