Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,26 @@
|
|
| 1 |
import os
|
| 2 |
import zipfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import torch
|
| 4 |
import torch.nn as nn
|
| 5 |
import torch.optim as optim
|
|
@@ -197,6 +218,6 @@ with desc_block:
|
|
| 197 |
image_input = gr.Image(type="pil", label="Upload Fruit Image", image_mode="RGB", height=256, width=256)
|
| 198 |
pred_output = gr.Textbox(label="Prediction Result")
|
| 199 |
predict_button = gr.Button("Classify Image")
|
| 200 |
-
predict_button.click(fn=predict_image, inputs=image_input, outputs=pred_output)
|
| 201 |
|
| 202 |
desc_block.launch()
|
|
|
|
| 1 |
import os
|
| 2 |
import zipfile
|
| 3 |
+
|
| 4 |
+
zip_file = "Fruits_datasets.zip"
|
| 5 |
+
dataset_folder = "./Data"
|
| 6 |
+
|
| 7 |
+
# Unzip only if not already done
|
| 8 |
+
if not os.path.exists(dataset_folder):
|
| 9 |
+
print("Extracting dataset from uploaded zip...")
|
| 10 |
+
with zipfile.ZipFile(zip_file, 'r') as zip_ref:
|
| 11 |
+
zip_ref.extractall(".")
|
| 12 |
+
else:
|
| 13 |
+
print("Dataset already extracted.")
|
| 14 |
+
|
| 15 |
+
# Now you can access:
|
| 16 |
+
for cls in os.listdir(dataset_folder):
|
| 17 |
+
print("Class:", cls)
|
| 18 |
+
cls_path = os.path.join(dataset_folder, cls)
|
| 19 |
+
print("Files:", os.listdir(cls_path))
|
| 20 |
+
|
| 21 |
+
"""
|
| 22 |
+
import os
|
| 23 |
+
import zipfile
|
| 24 |
import torch
|
| 25 |
import torch.nn as nn
|
| 26 |
import torch.optim as optim
|
|
|
|
| 218 |
image_input = gr.Image(type="pil", label="Upload Fruit Image", image_mode="RGB", height=256, width=256)
|
| 219 |
pred_output = gr.Textbox(label="Prediction Result")
|
| 220 |
predict_button = gr.Button("Classify Image")
|
| 221 |
+
predict_button.click(fn=predict_image, inputs=image_input, outputs=pred_output)"""
|
| 222 |
|
| 223 |
desc_block.launch()
|