Upload folder using huggingface_hub
Browse files
script.py
CHANGED
|
@@ -102,11 +102,12 @@ def make_submission(test_metadata, model_path, model_name, output_csv_path="./su
|
|
| 102 |
model = PytorchWorker()
|
| 103 |
data = LoadImagesAndLabels(test_metadata, VALID_AUG, mode='test')
|
| 104 |
predictions = []
|
|
|
|
| 105 |
for image in data:
|
| 106 |
output = model.predict_image(image)
|
| 107 |
string_label_dup = LABELS.get(str(np.argmax(output)), 'Acanthophis antarcticus')
|
| 108 |
prediction_class = ORIGINAL_LABELS.get(string_label_dup, 1)
|
| 109 |
-
predictions.append(
|
| 110 |
print(predictions)
|
| 111 |
|
| 112 |
test_metadata["class_id"] = predictions
|
|
@@ -128,6 +129,9 @@ if __name__ == "__main__":
|
|
| 128 |
metadata_file_path = "./SnakeCLEF2024_TestMetadata.csv"
|
| 129 |
test_metadata = pd.read_csv(metadata_file_path)
|
| 130 |
|
|
|
|
|
|
|
|
|
|
| 131 |
make_submission(
|
| 132 |
test_metadata=test_metadata,
|
| 133 |
model_path=MODEL_PATH,
|
|
|
|
| 102 |
model = PytorchWorker()
|
| 103 |
data = LoadImagesAndLabels(test_metadata, VALID_AUG, mode='test')
|
| 104 |
predictions = []
|
| 105 |
+
|
| 106 |
for image in data:
|
| 107 |
output = model.predict_image(image)
|
| 108 |
string_label_dup = LABELS.get(str(np.argmax(output)), 'Acanthophis antarcticus')
|
| 109 |
prediction_class = ORIGINAL_LABELS.get(string_label_dup, 1)
|
| 110 |
+
predictions.append(prediction_class)
|
| 111 |
print(predictions)
|
| 112 |
|
| 113 |
test_metadata["class_id"] = predictions
|
|
|
|
| 129 |
metadata_file_path = "./SnakeCLEF2024_TestMetadata.csv"
|
| 130 |
test_metadata = pd.read_csv(metadata_file_path)
|
| 131 |
|
| 132 |
+
# test_metadata = pd.DataFrame()
|
| 133 |
+
# test_metadata['filename'] = ['../sample.png', '../sample copy.png', '../sample copy 2.png']
|
| 134 |
+
# test_metadata['observation_id'] = [1, 2, 3]
|
| 135 |
make_submission(
|
| 136 |
test_metadata=test_metadata,
|
| 137 |
model_path=MODEL_PATH,
|