Spaces:
Sleeping
Sleeping
Habeeb Okunade
commited on
Commit
·
f119f72
1
Parent(s):
785b8f1
Update Training script
Browse files
train2.py
CHANGED
|
@@ -38,11 +38,12 @@ print(f"🔹 Loading processor from {MODEL_NAME}...")
|
|
| 38 |
processor = AutoImageProcessor.from_pretrained(MODEL_NAME)
|
| 39 |
|
| 40 |
def transform(example):
|
| 41 |
-
# Determine image column
|
| 42 |
-
image_column = "image" if "image" in example else
|
|
|
|
| 43 |
images = example[image_column]
|
| 44 |
|
| 45 |
-
# Ensure list
|
| 46 |
if not isinstance(images, list):
|
| 47 |
images = [images]
|
| 48 |
|
|
@@ -56,7 +57,7 @@ def transform(example):
|
|
| 56 |
raise ValueError(f"Unknown type for image: {type(img)}")
|
| 57 |
processed_images.append(img)
|
| 58 |
|
| 59 |
-
# Convert
|
| 60 |
inputs = processor(images=processed_images, return_tensors="pt")
|
| 61 |
|
| 62 |
# Handle labels
|
|
|
|
| 38 |
processor = AutoImageProcessor.from_pretrained(MODEL_NAME)
|
| 39 |
|
| 40 |
def transform(example):
|
| 41 |
+
# Determine correct image column
|
| 42 |
+
image_column = "image" if "image" in example else [c for c in example.keys() if c != "label"][0]
|
| 43 |
+
|
| 44 |
images = example[image_column]
|
| 45 |
|
| 46 |
+
# Ensure we always have a list
|
| 47 |
if not isinstance(images, list):
|
| 48 |
images = [images]
|
| 49 |
|
|
|
|
| 57 |
raise ValueError(f"Unknown type for image: {type(img)}")
|
| 58 |
processed_images.append(img)
|
| 59 |
|
| 60 |
+
# Convert to tensors (batched)
|
| 61 |
inputs = processor(images=processed_images, return_tensors="pt")
|
| 62 |
|
| 63 |
# Handle labels
|