Skip to content

Commit

Permalink
adding .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Cartucho committed Feb 10, 2019
1 parent 0277805 commit b95a424
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
results/
29 changes: 16 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
parser.add_argument('-q', '--quiet', help="minimalistic console output.", action="store_true")
# argparse receiving list of classes to be ignored
parser.add_argument('-i', '--ignore', nargs='+', type=str, help="ignore a list of classes.")
# argparse receiving list of classes with specific IoU
# argparse receiving list of classes with specific IoU (e.g., python main.py --set-class-iou person 0.7)
parser.add_argument('--set-class-iou', nargs='+', type=str, help="set IoU for a specific class.")
args = parser.parse_args()

Expand Down Expand Up @@ -230,7 +230,10 @@ def draw_plot_func(dictionary, n_classes, window_title, plot_title, x_label, out
#
if true_p_bar != "":
"""
Special case to draw in (green=true predictions) & (red=false predictions)
Special case to draw in:
- green -> TP: True Positives (object detected and matches ground-truth)
- red -> FP: False Positives (object detected but does not match ground-truth)
- orange -> FN: False Negatives (object not detected but present in the ground-truth)
"""
fp_sorted = []
tp_sorted = []
Expand Down Expand Up @@ -311,11 +314,11 @@ def draw_plot_func(dictionary, n_classes, window_title, plot_title, x_label, out
plt.close()

"""
Create a "tmp_files/" and "results/" directory
Create a ".temp_files/" and "results/" directory
"""
tmp_files_path = "tmp_files"
if not os.path.exists(tmp_files_path): # if it doesn't exist already
os.makedirs(tmp_files_path)
TEMP_FILES_PATH = ".temp_files"
if not os.path.exists(TEMP_FILES_PATH): # if it doesn't exist already
os.makedirs(TEMP_FILES_PATH)
results_files_path = "results"
if os.path.exists(results_files_path): # if it exist already
# reset the results directory
Expand Down Expand Up @@ -396,7 +399,7 @@ def draw_plot_func(dictionary, n_classes, window_title, plot_title, x_label, out


# dump bounding_boxes into a ".json" file
with open(tmp_files_path + "/" + file_id + "_ground_truth.json", 'w') as outfile:
with open(TEMP_FILES_PATH + "/" + file_id + "_ground_truth.json", 'w') as outfile:
json.dump(bounding_boxes, outfile)

gt_classes = list(gt_counter_per_class.keys())
Expand Down Expand Up @@ -466,7 +469,7 @@ def draw_plot_func(dictionary, n_classes, window_title, plot_title, x_label, out
#print(bounding_boxes)
# sort predictions by decreasing confidence
bounding_boxes.sort(key=lambda x:float(x['confidence']), reverse=True)
with open(tmp_files_path + "/" + class_name + "_predictions.json", 'w') as outfile:
with open(TEMP_FILES_PATH + "/" + class_name + "_predictions.json", 'w') as outfile:
json.dump(bounding_boxes, outfile)

"""
Expand All @@ -484,7 +487,7 @@ def draw_plot_func(dictionary, n_classes, window_title, plot_title, x_label, out
"""
Load predictions of that class
"""
predictions_file = tmp_files_path + "/" + class_name + "_predictions.json"
predictions_file = TEMP_FILES_PATH + "/" + class_name + "_predictions.json"
predictions_data = json.load(open(predictions_file))

"""
Expand Down Expand Up @@ -519,7 +522,7 @@ def draw_plot_func(dictionary, n_classes, window_title, plot_title, x_label, out
img = cv2.copyMakeBorder(img, 0, bottom_border, 0, 0, cv2.BORDER_CONSTANT, value=BLACK)
# assign prediction to ground truth object if any
# open ground-truth with that file_id
gt_file = tmp_files_path + "/" + file_id + "_ground_truth.json"
gt_file = TEMP_FILES_PATH + "/" + file_id + "_ground_truth.json"
ground_truth_data = json.load(open(gt_file))
ovmax = -1
gt_match = -1
Expand Down Expand Up @@ -706,8 +709,8 @@ def draw_plot_func(dictionary, n_classes, window_title, plot_title, x_label, out
results_file.write(text + "\n")
print(text)

# remove the tmp_files directory
shutil.rmtree(tmp_files_path)
# remove the temp_files directory
shutil.rmtree(TEMP_FILES_PATH)

"""
Count total of Predictions
Expand Down Expand Up @@ -786,7 +789,7 @@ def draw_plot_func(dictionary, n_classes, window_title, plot_title, x_label, out
# end Plot title
x_label = "Number of objects per class"
output_path = results_files_path + "/Predicted Objects Info.png"
to_show = False
to_show = True
plot_color = 'forestgreen'
true_p_bar = count_true_positives
draw_plot_func(
Expand Down

0 comments on commit b95a424

Please sign in to comment.