Spaces:
Runtime error
Runtime error
Fixed code to account for the hugging face dataset.
Browse files- app.py +17 -21
- gen2_images.csv +0 -0
- gen3_images.csv +0 -0
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -1,36 +1,32 @@
|
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
from pathlib import Path
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
import pandas as pd
|
|
|
|
| 6 |
from fastai.vision.all import *
|
| 7 |
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
df = pd.read_csv(csv_path)
|
| 11 |
-
df['file'] = df['file'].apply(lambda x: str(Path(image_dir) / x))
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
missing_files = df[~df['file_exists']]
|
| 16 |
-
if not missing_files.empty:
|
| 17 |
-
print("Warning: The following files are missing:")
|
| 18 |
-
print(missing_files['file'])
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
gen2_images_dir = "./gen2_images"
|
| 26 |
-
df_gen2 = create_dataframe(gen2_images_dir, gen2_images_csv)
|
| 27 |
-
|
| 28 |
-
gen3_images_csv = "./gen3_images.csv"
|
| 29 |
-
gen3_images_dir = "./gen3_images"
|
| 30 |
-
df_gen3 = create_dataframe(gen3_images_dir, gen3_images_csv)
|
| 31 |
-
|
| 32 |
-
df_gen2['label'] = 'Gen 2'
|
| 33 |
-
df_gen3['label'] = 'Gen 3'
|
| 34 |
|
| 35 |
def create_neither_dataframe(path):
|
| 36 |
file_paths = []
|
|
@@ -75,4 +71,4 @@ interface = gr.Interface(
|
|
| 75 |
live=True
|
| 76 |
)
|
| 77 |
|
| 78 |
-
interface.launch(share=True)
|
|
|
|
| 1 |
+
import io
|
| 2 |
import os
|
| 3 |
+
import tarfile
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
import pandas as pd
|
| 8 |
+
from datasets import load_dataset
|
| 9 |
from fastai.vision.all import *
|
| 10 |
|
| 11 |
+
# Load the dataset from Hugging Face
|
| 12 |
+
dataset = load_dataset("freddyal/smb_collection")
|
| 13 |
|
| 14 |
+
df = pd.DataFrame(dataset['train'])
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
def label_generation(file_name):
|
| 17 |
+
if "gen2_images" in file_name:
|
| 18 |
+
return "Gen 2"
|
| 19 |
+
elif "gen3_images" in file_name:
|
| 20 |
+
return "Gen 3"
|
| 21 |
+
else:
|
| 22 |
+
return "Non SMB"
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
df['label'] = df['__key__'].apply(label_generation)
|
| 26 |
|
| 27 |
+
df_gen2 = df[df['label'] == 'Gen 2']
|
| 28 |
|
| 29 |
+
df_gen3 = df[df['label'] == 'Gen 3']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
def create_neither_dataframe(path):
|
| 32 |
file_paths = []
|
|
|
|
| 71 |
live=True
|
| 72 |
)
|
| 73 |
|
| 74 |
+
interface.launch(share=True)
|
gen2_images.csv
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
gen3_images.csv
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
gradio~=4.44.0
|
| 2 |
fastai~=2.7.17
|
| 3 |
-
pandas~=2.2.0
|
|
|
|
|
|
| 1 |
gradio~=4.44.0
|
| 2 |
fastai~=2.7.17
|
| 3 |
+
pandas~=2.2.0
|
| 4 |
+
datasets~=3.0.0
|