-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feedback #12
base: feedback
Are you sure you want to change the base?
Feedback #12
Conversation
Merge pull request #1 from boostcampaitech7/main
organize validation fucntion
…ir in inference.py
- add csv_path - change result_path
Train optim
final Merge
Test_feature_streamlit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments
os.makedirs(dest_path) | ||
|
||
# 파일 이동 | ||
for file in files: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기에 try, except로 이동이 안 되었을 경우에는 어떤 오류때문인지 어떤 파일이 문제인지 출력해주면 좋을 거 같습니다. logging package를 활용하여 남겨주시면 좋습니다 (logging.info, logging.error).
new_train_info = train_info.copy() | ||
new_train_info['converted_image_path'] = "" | ||
|
||
pin = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분이 조금 직관적이지는 않습니다. 왜 "n01774384/sketch_10.JPEG"에서 멈추려고 하지? 라는 느낌이 들어 조금 더 general하게 코드를 만들 수도 있지 않을까란 생각이 들었습니다.
@@ -0,0 +1,152 @@ | |||
import os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전반적으로 조금 산만하다는 생각이 들어서 모듈화가 잘 되었다고 가정할 때의 main함수만 구성을 해봤습니다. 먼저, 지금 짜신 거처럼 코드를 짜고 동작이 되면 한 번 이런식으로 정리하는 습관이 좋은 거 같습니다.
def main(config):
set_seed(42)
device = "cuda" if torch.cuda.is_available() else "cpu"
pipe = initialize_pipeline(device)
preprocess = get_preprocessing_pipeline()
mapping = load_mapping(config['mapping_file'])
train_info = pd.read_csv(config['train_csv']).sort_values(by='image_path').reset_index(drop=True)
train_info['converted_image_path'] = ""
process_sketch_images(train_info, mapping, config, pipe, preprocess)
train_info.to_csv(config['new_train_csv'], index=False)
print(f"csv file saved")
config = {
"train_csv": "./data/train.csv",
"converted_data_dir": "./data/converted_images",
"sketch_data_dir": "./data/train",
"new_train_csv": "./data/new_train.csv",
"mapping_file": "./data/imagenet_synset_to_definition.txt"
}
if name == "main":
main(config)
@@ -0,0 +1,105 @@ | |||
import torch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transformer.py의 class를 상속받아 코드를 짜면 중복을 줄일 수 있을 거 같습니다. 저는 많은 파일을 만드는 것을 좋아하지 않아, 보통 transformer.py 아래에 하나의 클래스를 더 만들어 상속형식으로 정의를 합니다.
- `train.py`: Script to train the model | ||
|
||
|
||
## Usage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분 좋기는 한데 저는 보통 잠을 자는 시간에 많은 코드를 돌려놓고 아침에 확인하는 편이라서, train.sh을 만들고 이 안에서 다양한 python train.py -parameter = argument의 형식으로 여러 parameter의 조합을 돌리고 ablation study를 합니다. config.json파일을 직접 고쳐서 수정하는 것은 여러 실험을 할 때 적합하지 않은 거 같습니다.
cam = np.mean(cam, axis=0) # 여러 채널이 있는 경우 평균 | ||
|
||
# CAM 크기를 입력 이미지 크기에 맞게 조정 | ||
cam = cv2.resize(cam, (image.shape[3], image.shape[2])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
image는 (batch, channel, height, width) 형식이므로 image.shape[2] (height)과 image.shape[3] (width)이 되어야 하지 않나요?
status_text.text(f"Processing {image_type} image {i+1}/{total_images}") | ||
|
||
# Streamlit이 업데이트를 표시할 시간을 주기 위해 잠시 대기 | ||
time.sleep(0.01) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
보통은 st.progress()와 st.text()를 사용하여 업데이트합니다. time.sleep이 실행속도를 늦출 수도 있습니다.
@@ -0,0 +1,412 @@ | |||
import streamlit as st |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전반적으로 st.session_state에 저장되는 코드가 중복되고 있는 거 같은데, 아래와 같이 모듈화하시면 어떨까 싶습니다.
def initialize_session_state():
session_keys = ['original_dataset', 'sketch_dataset', 'info_df', 'model_loaded',
'model_load_success', 'misclassified', 'misclassified_dataset',
'misclassified_original_images', 'current_misclassified_index']
for key in session_keys:
if key not in st.session_state:
st.session_state[key] = None if 'index' not in key else 0
|
||
1. Prepare your data in the `data/` directory. | ||
2. Adjust the configuration in `configs/config.json` if needed. | ||
3. Run training: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diffusion model로 만든 이미지를 저장하고, 학습에 활용하시는 거 같은데 그 과정에 대해 실행하는 측면에서 알려주는 부분이 있으면 좋을 거 같습니다.
@@ -0,0 +1,26 @@ | |||
import os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
매우 큰 데이터셋의 경우, 파일을 하나씩 처리하는 것은 시간이 오래 걸릴 수 있습니다. 다중 스레드나 프로세스를 사용하여 성능을 개선할 수 있습니다.
No description provided.