Spaces:
Running
Running
Sadjad Alikhani
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -135,8 +135,8 @@ def plot_confusion_matrix_from_csv(csv_file_path, title, save_path):
|
|
135 |
data = pd.read_csv(csv_file_path)
|
136 |
|
137 |
# Extract ground truth and predictions
|
138 |
-
y_true = data['
|
139 |
-
y_pred = data['
|
140 |
|
141 |
# Compute confusion matrix
|
142 |
cm = confusion_matrix(y_true, y_pred)
|
@@ -229,7 +229,7 @@ class PrintCapture(io.StringIO):
|
|
229 |
|
230 |
# Function to load and display predefined images based on user selection
|
231 |
def display_predefined_images(percentage_idx):
|
232 |
-
percentage =
|
233 |
raw_image_path = os.path.join(RAW_PATH, f"percentage_{percentage}_complexity_16.png")
|
234 |
embeddings_image_path = os.path.join(EMBEDDINGS_PATH, f"percentage_{percentage}_complexity_16.png")
|
235 |
|
@@ -278,7 +278,7 @@ def load_module_from_path(module_name, file_path):
|
|
278 |
|
279 |
# Function to split dataset into training and test sets based on user selection
|
280 |
def split_dataset(channels, labels, percentage_idx):
|
281 |
-
percentage =
|
282 |
num_samples = channels.shape[0]
|
283 |
train_size = int(num_samples * percentage)
|
284 |
print(f'Number of Training Samples: {train_size}')
|
@@ -347,7 +347,7 @@ def identical_train_test_split(output_emb, output_raw, labels, percentage_idx):
|
|
347 |
indices = torch.randperm(N) # Randomly shuffle the indices
|
348 |
|
349 |
# Calculate the split index
|
350 |
-
split_index = int(N *
|
351 |
print(f'Training Size: {split_index}')
|
352 |
|
353 |
# Split indices into train and test
|
@@ -429,7 +429,7 @@ def process_hdf5_file(uploaded_file, percentage_idx):
|
|
429 |
print(f"Output Raw Shape: {output_raw.shape}")
|
430 |
|
431 |
print(f'percentage_idx: {percentage_idx}')
|
432 |
-
print(f'percentage_value: {
|
433 |
train_data_emb, test_data_emb, train_data_raw, test_data_raw, train_labels, test_labels = identical_train_test_split(output_emb.view(len(output_emb),-1),
|
434 |
output_raw.view(len(output_raw),-1),
|
435 |
labels,
|
|
|
135 |
data = pd.read_csv(csv_file_path)
|
136 |
|
137 |
# Extract ground truth and predictions
|
138 |
+
y_true = data['Target']
|
139 |
+
y_pred = data['Top-1 Prediction']
|
140 |
|
141 |
# Compute confusion matrix
|
142 |
cm = confusion_matrix(y_true, y_pred)
|
|
|
229 |
|
230 |
# Function to load and display predefined images based on user selection
|
231 |
def display_predefined_images(percentage_idx):
|
232 |
+
percentage = percentage_values_los[percentage_idx]
|
233 |
raw_image_path = os.path.join(RAW_PATH, f"percentage_{percentage}_complexity_16.png")
|
234 |
embeddings_image_path = os.path.join(EMBEDDINGS_PATH, f"percentage_{percentage}_complexity_16.png")
|
235 |
|
|
|
278 |
|
279 |
# Function to split dataset into training and test sets based on user selection
|
280 |
def split_dataset(channels, labels, percentage_idx):
|
281 |
+
percentage = percentage_values_los[percentage_idx] / 100
|
282 |
num_samples = channels.shape[0]
|
283 |
train_size = int(num_samples * percentage)
|
284 |
print(f'Number of Training Samples: {train_size}')
|
|
|
347 |
indices = torch.randperm(N) # Randomly shuffle the indices
|
348 |
|
349 |
# Calculate the split index
|
350 |
+
split_index = int(N * percentage_values_los[percentage_idx]/100)
|
351 |
print(f'Training Size: {split_index}')
|
352 |
|
353 |
# Split indices into train and test
|
|
|
429 |
print(f"Output Raw Shape: {output_raw.shape}")
|
430 |
|
431 |
print(f'percentage_idx: {percentage_idx}')
|
432 |
+
print(f'percentage_value: {percentage_values_los[percentage_idx]}')
|
433 |
train_data_emb, test_data_emb, train_data_raw, test_data_raw, train_labels, test_labels = identical_train_test_split(output_emb.view(len(output_emb),-1),
|
434 |
output_raw.view(len(output_raw),-1),
|
435 |
labels,
|