forked from kookmin-sw/cap-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore : cctv 수정
- Loading branch information
Showing
23 changed files
with
212 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
*.npy | ||
|
||
output/ | ||
datasets/ | ||
pretrained/ | ||
__pycache__/ | ||
condor_log/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import json | ||
import os | ||
|
||
import torch | ||
from PIL import Image | ||
|
||
from lib.utils.caption import Caption | ||
|
||
|
||
class CUHKPEDESDataset(torch.utils.data.Dataset): | ||
def __init__( | ||
self, | ||
root, | ||
ann_file, | ||
use_onehot=True, | ||
max_length=100, | ||
transforms=None, | ||
): | ||
self.root = root | ||
self.use_onehot = use_onehot | ||
self.max_length = max_length | ||
self.transforms = transforms | ||
|
||
self.img_dir = os.path.join(self.root, "imgs") | ||
# self.img_dir = self.root | ||
|
||
print("loading annotations into memory...") | ||
dataset = json.load(open(ann_file, "r")) | ||
self.dataset = dataset["annotations"] | ||
|
||
def __getitem__(self, index): | ||
""" | ||
Args: | ||
index(int): Index | ||
Returns: | ||
tuple: (images, labels, captions) | ||
""" | ||
data = self.dataset[index] | ||
|
||
img_path = data["file_path"] | ||
img = Image.open(os.path.join(self.img_dir, img_path)).convert("RGB") | ||
|
||
if self.use_onehot: | ||
caption = data["onehot"] | ||
caption = torch.tensor(caption) | ||
caption = Caption([caption], max_length=self.max_length, padded=False) | ||
else: | ||
caption = data["sentence"] | ||
caption = Caption(caption) | ||
|
||
caption.add_field("img_path", img_path) | ||
|
||
label = int(data["id"]) | ||
|
||
# Convert label to string representation and then to tensor of ASCII values | ||
label_str = str(label) | ||
label_tensor = torch.tensor([ord(char) for char in label_str]) | ||
caption.add_field("id", label_tensor) | ||
|
||
if self.transforms is not None: | ||
img = self.transforms(img) | ||
|
||
query = data["sentence"] | ||
|
||
return img, caption, index, query | ||
|
||
def __len__(self): | ||
return len(self.dataset) | ||
|
||
def get_id_info(self, index): | ||
image_id = self.dataset[index]["image_id"] | ||
pid = self.dataset[index]["id"] | ||
return image_id, pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,7 @@ def main(): | |
) | ||
parser.add_argument( | ||
"--top-k", | ||
default=10, | ||
default=400, | ||
type=int, | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import json | ||
import os | ||
import shutil | ||
|
||
# JSON 파일 경로 | ||
json_file_path = '/home/jongbin/Documents/GitHub/capstone-2024-14/capstone-2024-14/ai/TextReID/output/output.json' | ||
|
||
# 이미지를 복사할 대상 폴더 경로 | ||
destination_folder = '/home/jongbin/Desktop/copied_images' | ||
|
||
# 대상 폴더가 존재하지 않으면 생성 | ||
if not os.path.exists(destination_folder): | ||
os.makedirs(destination_folder) | ||
|
||
# JSON 파일 읽기 | ||
with open(json_file_path, 'r') as json_file: | ||
data = json.load(json_file) | ||
|
||
# 이미지 경로 리스트 | ||
image_paths = [entry['img_path'] for entry in data if 'img_path' in entry] | ||
|
||
# 이미지 복사 | ||
for img_path in image_paths: | ||
if os.path.exists(img_path): | ||
shutil.copy(img_path, destination_folder) | ||
print(f"Copied: {img_path}") | ||
else: | ||
print(f"File not found: {img_path}") | ||
|
||
print("Image copying completed.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
python3 imgSearch.py --data_path /home/jongbin/Desktop/yolo/164 --topk 20 --query /home/jongbin/Desktop/yolo/164/1_2024-05-14_16-07-56_155.jpg | ||
python3 imgSearch.py --data_path /home/jongbin/Desktop/copied_images --topk 20 --query /home/jongbin/Desktop/copied_images/5_2024-05-14_16-26-33_133.jpg | ||
|
||
python3 imgSearch.py --data_path /home/jongbin/Desktop/yolo/23 --topk 40 --query /home/jongbin/Desktop/copied_images/1_2024-05-14_16-07-56_387.jpg | ||
|
||
/home/jongbin/Desktop/yolo/164 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.