Spaces:
Sleeping
Sleeping
Update hmc_grad.py
Browse files- hmc_grad.py +2 -14
hmc_grad.py
CHANGED
|
@@ -51,10 +51,7 @@ PREDICTION_TO_STRING = ["A", "B", "C", "D"]
|
|
| 51 |
Prepare the Classifier Model.
|
| 52 |
"""
|
| 53 |
|
| 54 |
-
#
|
| 55 |
-
# GITHUB_URL = "https://raw.githubusercontent.com/GabrielEdradan/HMC-Grad/main/image_classifier.pth"
|
| 56 |
-
# MODEL_PATH = "/content/model.pth"
|
| 57 |
-
# os.system(f"wget {GITHUB_URL} -O {MODEL_PATH}")
|
| 58 |
model_state_dict = torch.load("image_classifier.pth")
|
| 59 |
|
| 60 |
# Define the model class
|
|
@@ -523,18 +520,9 @@ def grade_and_analyze(item_answers, img_cor_arr, img_scr_arr, itm_ana_arr, scr_a
|
|
| 523 |
return corrected_image
|
| 524 |
|
| 525 |
"""## THE INTERFACE
|
| 526 |
-
Use Gradio to create a user-friendly interface.
|
| 527 |
"""
|
| 528 |
|
| 529 |
-
# Download the sample images for the demo interface
|
| 530 |
-
# SAMPLE_IMAGES_FOLDER_URL = "https://raw.githubusercontent.com/GabrielEdradan/HMC-Grad/main/sample_images/"
|
| 531 |
-
# IMAGE_SAVE_PATH = "/content/"
|
| 532 |
-
|
| 533 |
-
# NUM_OF_SAMPLES = 2
|
| 534 |
-
# for i in range(1, NUM_OF_SAMPLES + 1):
|
| 535 |
-
# suffix = f"sample_{i}.jpg"
|
| 536 |
-
# os.system(f"wget {SAMPLE_IMAGES_FOLDER_URL}{suffix} -O {IMAGE_SAVE_PATH}{suffix}")
|
| 537 |
-
|
| 538 |
# Define the interface function
|
| 539 |
# Takes in two inputs: the correction key (string) and the answer sheet images (Array[Array[image paths]])
|
| 540 |
def interface_function(correction_key_string, *images):
|
|
|
|
| 51 |
Prepare the Classifier Model.
|
| 52 |
"""
|
| 53 |
|
| 54 |
+
# Load the model's state dictionary
|
|
|
|
|
|
|
|
|
|
| 55 |
model_state_dict = torch.load("image_classifier.pth")
|
| 56 |
|
| 57 |
# Define the model class
|
|
|
|
| 520 |
return corrected_image
|
| 521 |
|
| 522 |
"""## THE INTERFACE
|
| 523 |
+
Use Gradio to create a user-friendly interface. Set the interface function here, and app.py will import it and run Gradio.
|
| 524 |
"""
|
| 525 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 526 |
# Define the interface function
|
| 527 |
# Takes in two inputs: the correction key (string) and the answer sheet images (Array[Array[image paths]])
|
| 528 |
def interface_function(correction_key_string, *images):
|