Spaces:
Running
Running
Sadjad Alikhani
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -205,18 +205,6 @@ def handle_user_choice(choice, percentage_idx=None, uploaded_file=None):
|
|
205 |
else:
|
206 |
return "Invalid choice", "Invalid choice", "" # Return empty string for console output
|
207 |
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
# Custom class to capture print output
|
221 |
class PrintCapture(io.StringIO):
|
222 |
def __init__(self):
|
@@ -249,15 +237,6 @@ def display_predefined_images(percentage_idx):
|
|
249 |
|
250 |
return raw_image, embeddings_image
|
251 |
|
252 |
-
# Updated los_nlos_classification to handle missing outputs properly
|
253 |
-
#def los_nlos_classification(file, percentage_idx):
|
254 |
-
# if file is not None:
|
255 |
-
# raw_cm_image, emb_cm_image, console_output = process_hdf5_file(file, percentage_idx)
|
256 |
-
# return raw_cm_image, emb_cm_image, console_output
|
257 |
-
# else:
|
258 |
-
# raw_image, embeddings_image = display_predefined_images(percentage_idx)
|
259 |
-
# return raw_image, embeddings_image, "No file uploaded. Displaying predefined images."
|
260 |
-
|
261 |
def los_nlos_classification(file, percentage_idx):
|
262 |
if file is not None:
|
263 |
raw_cm_image, emb_cm_image, console_output = process_hdf5_file(file, percentage_idx)
|
@@ -271,13 +250,6 @@ def create_random_image(size=(300, 300)):
|
|
271 |
random_image = np.random.rand(*size, 3) * 255
|
272 |
return Image.fromarray(random_image.astype('uint8'))
|
273 |
|
274 |
-
# Function to load the pre-trained model from your cloned repository
|
275 |
-
def load_custom_model():
|
276 |
-
from lwm_model import LWM # Assuming the model is defined in lwm_model.py
|
277 |
-
model = LWM() # Modify this according to your model initialization
|
278 |
-
model.eval()
|
279 |
-
return model
|
280 |
-
|
281 |
import importlib.util
|
282 |
|
283 |
# Function to dynamically load a Python module from a given file path
|
@@ -350,7 +322,6 @@ def plot_confusion_matrix(y_true, y_pred, title):
|
|
350 |
plt.savefig(f"{title}.png")
|
351 |
return Image.open(f"{title}.png")
|
352 |
|
353 |
-
|
354 |
def identical_train_test_split(output_emb, output_raw, labels, percentage_idx):
|
355 |
N = output_emb.shape[0] # Get the total number of samples
|
356 |
|
@@ -502,7 +473,7 @@ with gr.Blocks(css="""
|
|
502 |
choice_radio = gr.Radio(choices=["Use Default Dataset", "Upload Dataset"], label="Choose how to proceed", value="Use Default Dataset")
|
503 |
|
504 |
# Dropdown for selecting percentage for predefined data
|
505 |
-
percentage_dropdown_los = gr.Dropdown(choices=
|
506 |
|
507 |
# File uploader for dataset (only visible if user chooses to upload a dataset)
|
508 |
file_input = gr.File(label="Upload HDF5 Dataset", file_types=[".h5"], visible=False)
|
|
|
205 |
else:
|
206 |
return "Invalid choice", "Invalid choice", "" # Return empty string for console output
|
207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
# Custom class to capture print output
|
209 |
class PrintCapture(io.StringIO):
|
210 |
def __init__(self):
|
|
|
237 |
|
238 |
return raw_image, embeddings_image
|
239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
def los_nlos_classification(file, percentage_idx):
|
241 |
if file is not None:
|
242 |
raw_cm_image, emb_cm_image, console_output = process_hdf5_file(file, percentage_idx)
|
|
|
250 |
random_image = np.random.rand(*size, 3) * 255
|
251 |
return Image.fromarray(random_image.astype('uint8'))
|
252 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
import importlib.util
|
254 |
|
255 |
# Function to dynamically load a Python module from a given file path
|
|
|
322 |
plt.savefig(f"{title}.png")
|
323 |
return Image.open(f"{title}.png")
|
324 |
|
|
|
325 |
def identical_train_test_split(output_emb, output_raw, labels, percentage_idx):
|
326 |
N = output_emb.shape[0] # Get the total number of samples
|
327 |
|
|
|
473 |
choice_radio = gr.Radio(choices=["Use Default Dataset", "Upload Dataset"], label="Choose how to proceed", value="Use Default Dataset")
|
474 |
|
475 |
# Dropdown for selecting percentage for predefined data
|
476 |
+
percentage_dropdown_los = gr.Dropdown(choices=[f"{value:.3f}" for value in percentage_values_los], value=f"{percentage_values_los[0]:.3f}", label="Percentage of Data for Training")
|
477 |
|
478 |
# File uploader for dataset (only visible if user chooses to upload a dataset)
|
479 |
file_input = gr.File(label="Upload HDF5 Dataset", file_types=[".h5"], visible=False)
|