Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ran_dataset/F1P111_Spot_Center_200730_PCA.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ran_dataset/F1P111_Spot_Side1_200730_PCA.JPG
Binary file added Ran_dataset/F1P111_Spot_Side2_200730_PCA.JPG
Binary file added Ran_dataset/F1P111_Vein_Side1_200731_Aligned.jpg
Binary file added Ran_dataset/F1P111_Vein_Side2_200731_Aligned.jpg
Binary file added Ran_dataset/F1P115_Spot_Center_200731_PCA.JPG
Binary file added Ran_dataset/F1P115_Spot_Side1_200731_PCA.JPG
Binary file added Ran_dataset/F1P115_Spot_Side2_200731_PCA.JPG
Binary file added Ran_dataset/F1P115_Vein_Side1_200802_Aligned.jpg
Binary file added Ran_dataset/F1P115_Vein_Side2_200802_Aligned.jpg
Binary file added Ran_dataset/Figure_1.png
Binary file added Ran_dataset/Image_Alignment_Output/Figure_1.png
Binary file added Ran_dataset/Image_Alignment_Output/Keypoints.png
4 changes: 2 additions & 2 deletions example_dataset/F1P111_Vein_Center_200731_labels.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"cy": 473
},
"region_attributes": {
"label ": "center_vein_top"
"label": "center_vein_top"
}
},
"1": {
Expand All @@ -23,7 +23,7 @@
"cy": 432
},
"region_attributes": {
"label ": "center_vein_bottom"
"label": "center_vein_bottom"
}
}
}
Expand Down
Binary file added output_results/F1P111_Center_Vein_Aligned.jpg
Binary file added output_results/F1P111_Spot_Center_RAW.jpg
Binary file added output_results/F1P111_Spot_Side1_200730_PCA.JPG
Binary file added output_results/F1P111_Spot_Side2_200730_PCA.JPG
Binary file added output_results/F1P111_Vein_Center_RAW.jpg
Binary file added output_results/F1P115_Spot_Center_200731_PCA.JPG
Binary file added output_results/F1P115_Spot_Side1_200731_PCA.JPG
Binary file added output_results/tps_comparison.png
Binary file added output_results/tps_original_with_points.jpg
Binary file added output_results/tps_warped_petal.jpg
Binary file added src/F1P111_Spot_Center_200730_combined.JPG
Binary file added src/F1P111_Spot_Center_200730_pca.JPG
Binary file added src/F1P111_Spot_Side1_200730_combined.JPG
Binary file added src/F1P111_Spot_Side1_200730_pca.JPG
Binary file added src/F1P111_Spot_Side2_200730_combined.JPG
Binary file added src/F1P111_Spot_Side2_200730_pca.JPG
Binary file added src/F1P111_Vein_Center_200731_aligned.jpg
Binary file added src/F1P111_Vein_Side1_200731_aligned.jpg
Binary file added src/F1P111_Vein_Side2_200731_aligned.jpg
Binary file added src/F1P115_Spot_Center_200731_combined.JPG
Binary file added src/F1P115_Spot_Center_200731_pca.JPG
Binary file added src/F1P115_Spot_Side1_200731_combined.JPG
Binary file added src/F1P115_Spot_Side1_200731_pca.JPG
Binary file added src/F1P115_Spot_Side2_200731_combined.JPG
Binary file added src/F1P115_Spot_Side2_200731_pca.JPG
Binary file added src/F1P115_Vein_Center_200802_aligned.jpg
Binary file added src/F1P115_Vein_Side1_200802_aligned.jpg
Binary file added src/F1P115_Vein_Side2_200802_aligned.jpg
29 changes: 24 additions & 5 deletions src/JSON_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ def parse_annotation(image_name, project_dir, group_attr=None, id_attr=None):
data_list = data[top_layer]['regions']

for annotation in data_list:
#print(data_list)
if group_attr: # if an attribute to group by is specified
if (len(annotation['region_attributes']) == 0) and (len(data_list) == 1):
attr = "bounding_box"
else:
attr = annotation['region_attributes'][group_attr]
#print("testing annotation['region_attributes']: ")
#print(annotation['region_attributes'])
#print(group_attr)
#print(filepath)
attr = annotation['region_attributes'][group_attr] #error spotted here
if id_attr: # if an attribute to id by is specified
if attr not in new_dict.keys():
new_dict[attr] = {}
Expand Down Expand Up @@ -90,14 +95,17 @@ def img_crop(image_filename,file_path):
'''
#create full file routing information
image_full = os.path.join(file_path,image_filename)
print(image_full)
#print(image_full)
#read the image
img = cv.imread(image_full,cv.IMREAD_COLOR)
img = cv.imread(image_full,cv.IMREAD_COLOR) #think this is altering the colors.
#print('image type:', type(img))
#img = cv.UMat(img) #gpu acceleration
img = cv.cvtColor(img, cv.COLOR_BGR2RGB) #possible fix for color issue. fixed.
assert not isinstance(img,type(None)), 'image not found'

#Get Truncated Dictionary:
new_dict = parse_annotation(image_filename,file_path, group_attr='label')
print(new_dict)
#print(new_dict)
#Parse through each object's data for rectangle objects
crop_key = 'bounding_box'
if crop_key in new_dict:
Expand All @@ -111,7 +119,6 @@ def img_crop(image_filename,file_path):

else:
raise ValueError("Image crop failed: \n Annotation key " + crop_key + " not found in annotations file for " + image_filename)

return croppedImg, new_dict


Expand Down Expand Up @@ -184,6 +191,15 @@ def main():
for file in files:
if not file.endswith("_labels.json"):
print(parse_annotation(file, sys.argv[1], group_attr='label'), '\n')
img_crop(file, sys.argv[1])
print('\n')
'''
img = cv.imread(file, cv.IMREAD_COLOR)
display_annotations(parse_annotation(file, sys.argv[1], group_attr='label'), img)
print('\n')
'''



# img = cv.imread(image_filename,cv2.IMREAD_COLOR)
# cv.imshow('Image loaded with annotations layer applied!',img)
Expand All @@ -205,3 +221,6 @@ def main():

#main()

if __name__ == "__main__":
main()

101 changes: 101 additions & 0 deletions src/LogReader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import pandas as pd
from pathlib import Path

LOG_FILE = "cpu_profile_gpu_2.log"


def load_log(logfile):
records = []

with open(logfile, "r", encoding="utf-8") as f:
for line in f:
line = line.strip()
if not line:
continue

parts = line.split(",")

timestamp = parts[0]
label = parts[1]

metrics = {}
for item in parts[2:]:
key, value = item.split("=")
metrics[key] = float(value)

records.append({
"timestamp": timestamp,
"label": label,
**metrics
})

df = pd.DataFrame(records)
df["timestamp"] = pd.to_datetime(df["timestamp"])
return df


def summarize_by_label(df):
summary = (
df.groupby("label")
.agg(
calls=("wall", "count"),
wall_mean=("wall", "mean"),
wall_min=("wall", "min"),
wall_max=("wall", "max"),
cpu_mean=("cpu", "mean"),
cpu_max=("cpu", "max"),
user_mean=("user", "mean"),
sys_mean=("sys", "mean"),
cv_threads=("cv_threads", "max"),
)
.sort_values("wall_mean", ascending=False)
)

return summary


def print_summary(summary):
pd.set_option("display.float_format", "{:.4f}".format)

print("\n=== CPU PROFILING SUMMARY (by label) ===\n")
print(summary)
print("\nLegend:")
print(" wall_* : wall-clock seconds")
print(" cpu_* : effective CPU utilization (%)")
print(" calls : number of profiled invocations")
print(" cv_threads : OpenCV internal thread count\n")


def detect_thread_changes(df):
changed = df[df["threads_start"] != df["threads_end"]]

if not changed.empty:
print("\n⚠ Thread count changed during profiling blocks:\n")
print(changed[[
"timestamp", "label",
"threads_start", "threads_end"
]])
else:
print("\n✓ No thread count changes detected\n")


def main():
logfile = Path(LOG_FILE)

if not logfile.exists():
raise FileNotFoundError(f"Log file not found: {logfile}")

df = load_log(logfile)

summary = summarize_by_label(df)
print_summary(summary)

detect_thread_changes(df)

# Optional CSV export for plotting
summary.to_csv("cpu_profile_summary.csv")
print("Summary written to cpu_profile_summary.csv")


if __name__ == "__main__":
main()
48 changes: 0 additions & 48 deletions src/data_processing.py

This file was deleted.

Loading