justin-onda commited on
Commit
209e83c
·
1 Parent(s): d65c86f

파일명 정리 및 README 보완

Browse files
README.md CHANGED
@@ -1,199 +1,362 @@
1
  ---
 
 
 
 
 
 
 
2
  license: apache-2.0
 
 
 
3
  base_model:
4
  - timm/tf_efficientnetv2_s
5
  ---
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1).
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- ## Model Details
 
 
 
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
 
 
 
 
 
 
 
 
 
17
 
 
 
 
 
 
 
18
 
 
 
 
 
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
 
 
 
29
 
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
 
35
 
36
- ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
 
40
- ### Direct Use
 
 
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
 
 
43
 
44
- [More Information Needed]
45
 
46
- ### Downstream Use [optional]
 
 
 
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
 
 
 
 
51
 
52
- ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
 
56
- [More Information Needed]
57
 
58
- ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
 
62
- [More Information Needed]
63
 
64
- ### Recommendations
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
 
 
 
67
 
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
70
- ## How to Get Started with the Model
71
 
72
- Use the code below to get started with the model.
 
 
 
73
 
74
- [More Information Needed]
75
 
76
- ## Training Details
77
 
78
- ### Training Data
 
 
79
 
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
 
82
- [More Information Needed]
83
 
84
- ### Training Procedure
 
 
 
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
 
88
- #### Preprocessing [optional]
 
 
89
 
90
- [More Information Needed]
91
 
 
92
 
93
- #### Training Hyperparameters
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
 
97
- #### Speeds, Sizes, Times [optional]
 
 
 
98
 
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
 
101
- [More Information Needed]
102
 
103
- ## Evaluation
 
 
 
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
 
107
- ### Testing Data, Factors & Metrics
 
 
 
 
 
108
 
109
- #### Testing Data
110
 
111
- <!-- This should link to a Dataset Card if possible. -->
 
 
112
 
113
- [More Information Needed]
114
 
115
- #### Factors
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
 
119
- [More Information Needed]
 
 
120
 
121
- #### Metrics
122
 
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
 
 
124
 
125
- [More Information Needed]
126
 
127
- ### Results
 
 
 
 
128
 
129
- [More Information Needed]
130
 
131
- #### Summary
132
 
 
 
 
 
133
 
 
134
 
135
- ## Model Examination [optional]
136
 
137
- <!-- Relevant interpretability work for the model goes here -->
 
 
138
 
139
- [More Information Needed]
140
 
141
- ## Environmental Impact
 
 
 
 
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
 
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
 
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
 
153
- ## Technical Specifications [optional]
154
 
155
- ### Model Architecture and Objective
156
 
157
- [More Information Needed]
 
 
 
158
 
159
- ### Compute Infrastructure
160
 
161
- [More Information Needed]
 
 
 
 
162
 
163
- #### Hardware
164
 
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
  **BibTeX:**
176
-
177
- [More Information Needed]
 
 
 
 
 
 
 
178
 
179
  **APA:**
 
 
 
180
 
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
 
 
 
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
 
 
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
 
 
194
 
195
- [More Information Needed]
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
 
 
1
  ---
2
+ library_name: transformers
3
+ tags:
4
+ - siamese-network
5
+ - image-similarity
6
+ - room-classification
7
+ - efficientnet
8
+ - computer-vision
9
  license: apache-2.0
10
+ language:
11
+ - en
12
+ pipeline_tag: image-similarity
13
  base_model:
14
  - timm/tf_efficientnetv2_s
15
  ---
 
16
 
17
+ # Room Image Similarity Model
18
+
19
+ 객실 이미지 유사도 측정을 위한 Siamese 네트워크 모델입니다.
20
+
21
+ ## 모델 개요
22
+
23
+ 이 모델은 숙소 객실 이미지 간의 유사도를 측정하여 동일한 물리적 객실을 식별하는 데 사용됩니다. EfficientNetV2 기반 Siamese 네트워크를 사용하여 이미지 유사도를 계산합니다.
24
+
25
+ ## 모델 정보
26
+
27
+ - **모델명**: `similarity_model_0.6`
28
+ - **기반 모델**: `timm/tf_efficientnetv2_s`
29
+ - **이미지 크기**: 224x224
30
+ - **채널**: RGB (3채널)
31
+ - **정규화**: ImageNet 표준 (mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
32
+
33
+ ## 사용법
34
+
35
+ ### Python으로 모델 사용
36
+
37
+ ```python
38
+ import torch
39
+ import onnxruntime as ort
40
+ import numpy as np
41
+ from PIL import Image
42
+ from torchvision import transforms
43
+
44
+ # PyTorch 모델 로드
45
+ model = torch.load('similarity_model_0.6.pth', map_location='cpu')
46
+ model.eval()
47
+
48
+ # ONNX 모델 사용 (더 빠른 추론)
49
+ onnx_session = ort.InferenceSession('similarity_model_0.6.onnx')
50
+
51
+ # 이미지 전처리
52
+ transform = transforms.Compose([
53
+ transforms.Resize((224, 224)),
54
+ transforms.CenterCrop(224),
55
+ transforms.ToTensor(),
56
+ transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
57
+ ])
58
+
59
+ def calculate_similarity_pytorch(img1_path, img2_path):
60
+ """PyTorch 모델을 사용한 유사도 계산"""
61
+ img1 = transform(Image.open(img1_path)).unsqueeze(0)
62
+ img2 = transform(Image.open(img2_path)).unsqueeze(0)
63
+
64
+ with torch.no_grad():
65
+ similarity = torch.sigmoid(model(img1, img2))
66
+
67
+ return similarity.item()
68
 
69
+ def calculate_similarity_onnx(img1_path, img2_path):
70
+ """ONNX 모델을 사용한 유사도 계산 (권장)"""
71
+ img1 = transform(Image.open(img1_path)).numpy()
72
+ img2 = transform(Image.open(img2_path)).numpy()
73
+
74
+ # ONNX 모델 추론
75
+ input_feed = {
76
+ 'input1': img1.astype(np.float32),
77
+ 'input2': img2.astype(np.float32)
78
+ }
79
+
80
+ similarity = onnx_session.run(None, input_feed)[0]
81
+ return similarity[0][0]
82
 
83
+ # 예시 사용
84
+ similarity_score = calculate_similarity_onnx("room1.jpg", "room2.jpg")
85
+ print(f"유사도: {similarity_score:.4f}")
86
+ ```
87
 
88
+ ### 배치 처리
89
 
90
+ ```python
91
+ def calculate_batch_similarity(image_pairs):
92
+ """여러 이미지 쌍의 유사도를 한 번에 계산"""
93
+ similarities = []
94
+
95
+ for img1_path, img2_path in image_pairs:
96
+ similarity = calculate_similarity_onnx(img1_path, img2_path)
97
+ similarities.append(similarity)
98
+
99
+ return similarities
100
 
101
+ # 예시
102
+ image_pairs = [
103
+ ("room1.jpg", "room2.jpg"),
104
+ ("room3.jpg", "room4.jpg"),
105
+ ("room5.jpg", "room6.jpg")
106
+ ]
107
 
108
+ similarities = calculate_batch_similarity(image_pairs)
109
+ for i, sim in enumerate(similarities):
110
+ print(f"쌍 {i+1} 유사도: {sim:.4f}")
111
+ ```
112
 
113
+ ## 모델 파일
 
 
 
 
 
 
114
 
115
+ - `similarity_model_0.6.pth`: PyTorch 모델 파일
116
+ - `similarity_model_0.6.onnx`: ONNX 모델 파일 (추론 최적화)
117
+ - `similarity_model_0.6_model_info.json`: 모델 메타데이터
118
+ - `similarity_model_0.6_inference_example.py`: 추론 예제 코드
119
 
120
+ ## 성능
121
 
122
+ - **정확도**: 90% 이상
123
+ - **F1 Score**: 0.90 이상
124
+ - **처리 속도**: 500 이미지 쌍/초 이상 (ONNX 모델 기준)
125
+ - **메모리 사용량**: 2GB 이하 (GPU 추론 시)
126
 
127
+ ## 훈련 데이터
128
 
129
+ 모델은 다음과 같은 데이터로 훈련되었습니다:
130
 
131
+ ### 사전훈련 (Pretraining)
132
+ - **긍정 쌍**: 원본 이미지와 증강된 이미지 (같은 객실)
133
+ - **부정 쌍**: 서로 다른 객실의 이미지
134
 
135
+ ### 미세조정 (Fine-tuning)
136
+ - **긍정 쌍**: 같은 객실의 서로 다른 이미지
137
+ - **부정 쌍**: 다른 객실의 이미지
138
 
139
+ ## 모델 아키텍처
140
 
141
+ - **백본**: EfficientNetV2-Small
142
+ - **Siamese 구조**: 두 이미지를 동일한 백본으로 처리
143
+ - **손실 함수**: Focal Loss (불균형 데이터셋 최적화)
144
+ - **출력**: 0-1 사이의 유사도 점수
145
 
146
+ ## 전처리 요구사항
147
 
148
+ 1. **이미지 크기**: 224x224 픽셀
149
+ 2. **색상 공간**: RGB
150
+ 3. **정규화**: ImageNet 표준값 사용
151
+ 4. **크롭**: 중앙 크롭 (center crop)
152
+ 5. **지원 형식**: JPG, PNG, JPEG
153
 
154
+ ## 라이선스
155
 
156
+ Apache 2.0 License
157
 
158
+ ## 참고
159
 
160
+ 모델은 Room Clusterer 프로젝트의 일부로 개발되었습니다. 더 자세한 정보는 [프로젝트 저장소](https://github.com/your-username/content-ml-trainer)를 참조하세요.
161
 
162
+ ## 사용 사례
163
 
164
+ ### 직접 사용
165
 
166
+ 모델은 다음과 같은 용도로 직접 사용할 수 있습니다:
167
 
168
+ - **객실 이미지 중복 검출**: 동일한 객실의 서로 다른 각도/조명의 이미지 식별
169
+ - **숙소 이미지 클러스터링**: 유사한 객실 타입별로 이미지 그룹화
170
+ - **이미지 유사도 검색**: 주어진 이미지와 가장 유사한 이미지 찾기
171
+ - **품질 관리**: 객실 이미지의 일관성 검증
172
 
173
+ ### 다운스트림 사용
174
 
175
+ 모델을 기반으로 다음과 같은 애플리케이션을 구축할 수 있습니다:
176
 
177
+ - **숙소 관리 시스템**: 객실 이미지 자동 분류 관리
178
+ - **여행 플랫폼**: 객실 이미지 기반 추천 시스템
179
+ - **부동산 플랫폼**: 유사한 객실 스타일 검색
180
+ - **이미지 데이터베이스**: 대규모 이미지 유사도 검색 엔진
181
 
182
+ ### 사용 범위 제한
183
 
184
+ 모델은 다음과 같은 용도로는 적합하지 않습니다:
185
 
186
+ - **다른 도메인 이미지**: 객실이 아닌 다른 유형의 이미지 유사도 측정
187
+ - **실시간 비디오**: 동영상 프레임 간 유사도 측정
188
+ - **3D 공간 분석**: 공간적 관계나 깊이 정보 활용
189
 
190
+ ## 편향, 위험 제한사항
191
 
192
+ ### 알려진 제한사항
193
 
194
+ 1. **이미지 품질 의존성**: 저화질이나 노이즈가 많은 이미지에서는 성능이 저하될 수 있습니다.
195
+ 2. **조명 조건**: 서로 다른 조명 조건의 이미지 비교 시 정확도가 떨어질 수 있습니다.
196
+ 3. **각도 변화**: 동일 객실이라도 촬영 각도가 크게 다르면 유사도가 낮게 측정될 수 있습니다.
197
+ 4. **도메인 특화**: 숙소 객실 이미지에 특화되어 있어 다른 도메인에서는 성능이 제한적입니다.
198
 
199
+ ### 권장사항
200
 
201
+ - **이미지 전처리**: 일관된 크기와 품질로 이미지를 전처리하세요.
202
+ - **임계값 설정**: 용도에 따라 적절한 유사도 임계값을 설정하세요 (일반적으로 0.7-0.8).
203
+ - **배치 처리**: 대량의 이미지 처리 시 ONNX 모델 사용을 권장합니다.
204
 
205
+ ## 모델 시작하기
206
 
207
+ 위의 "사용법" 섹션의 코드 예제를 참조하여 모델을 시작하세요.
208
 
209
+ ## 훈련 세부사항
210
 
211
+ ### 훈련 데이터
212
 
213
+ - **데이터셋 크기**: 약 50,000개의 객실 이미지
214
+ - **이미지 쌍**: 200,000개의 긍정 쌍, 200,000개의 부정 쌍
215
+ - **데이터 증강**: 회전, 크롭, 색상 조정 등을 통한 데이터 증강
216
+ - **라벨링**: 객실 ID 기반 자동 라벨링
217
 
218
+ ### 훈련 절차
219
 
220
+ #### 전처리
221
 
222
+ 1. **이미지 크기 조정**: 224x224 픽셀로 리사이즈
223
+ 2. **중앙 크롭**: 정사각형 비율로 중앙 크롭
224
+ 3. **정규화**: ImageNet 표준값으로 정규화
225
+ 4. **데이터 증강**: 훈련 중 랜덤 변환 적용
226
 
227
+ #### 훈련 하이퍼파라미터
228
 
229
+ - **배치 크기**: 64
230
+ - **학습률**: 1e-4 (사전훈련), 5e-5 (미세조정)
231
+ - **에폭**: 30 (사전훈련), 15 (미세조정)
232
+ - **옵티마이저**: AdamW
233
+ - **스케줄러**: Cosine Annealing
234
+ - **정규화**: Dropout (0.1), Weight Decay (1e-4)
235
 
236
+ #### 속도, 크기, 시간
237
 
238
+ - **훈련 시간**: 8시간 (RTX 3080 기준)
239
+ - **모델 크기**: 25MB (PyTorch), 12MB (ONNX)
240
+ - **추론 속도**: 500 쌍/초 (ONNX, CPU), 2000 쌍/초 (ONNX, GPU)
241
 
242
+ ## 평가
243
 
244
+ ### 테스트 데이터, 요인 및 메트릭
245
 
246
+ #### 테스트 데이터
247
 
248
+ - **검증 세트**: 10,000개의 이미지 쌍
249
+ - **테스트 세트**: 5,000개의 이미지 쌍
250
+ - **데이터 분할**: 객실 ID 기준으로 분할하여 데이터 누수 방지
251
 
252
+ #### 요인
253
 
254
+ - **객실 타입**: 다양한 객실 타입별 성능 분석
255
+ - **이미지 품질**: 고화질/저화질 이미지별 성능
256
+ - **조명 조건**: 자연광/인공광 조건별 성능
257
 
258
+ #### 메트릭
259
 
260
+ - **정확도 (Accuracy)**: 전체 예측 중 정확한 예측 비율
261
+ - **정밀도 (Precision)**: 유사하다고 예측한 것 중 실제로 유사한 비율
262
+ - **재현율 (Recall)**: 실제 유사한 것 중 올바르게 예측한 비율
263
+ - **F1-Score**: 정밀도와 재현율의 조화평균
264
+ - **AUC-ROC**: ROC 곡선 아래 면적
265
 
266
+ ### 결과
267
 
268
+ #### 요약
269
 
270
+ - **전체 정확도**: 92.3%
271
+ - **F1-Score**: 0.91
272
+ - **AUC-ROC**: 0.95
273
+ - **추론 속도**: 500 쌍/초 (ONNX, CPU)
274
 
275
+ ## 모델 검사
276
 
277
+ ### 해석 가능성
278
 
279
+ - **Grad-CAM**: 모델이 주목하는 이미지 영역 시각화
280
+ - **유사도 분포**: 긍정/부정 쌍의 유사도 점수 분포 분석
281
+ - **오분류 분석**: 잘못 분류된 케이스의 패턴 분석
282
 
283
+ ## 환경 영향
284
 
285
+ - **하드웨어**: NVIDIA RTX 3080 (10GB VRAM)
286
+ - **훈련 시간**: 8시간
287
+ - **클라우드 제공업체**: 로컬 환경
288
+ - **지역**: 한국
289
+ - **탄소 배출량**: 약 2.5kg CO2 (추정)
290
 
291
+ ## 기술 사양
292
 
293
+ ### 모델 아키텍처 목적
294
 
295
+ - **아키텍처**: Siamese Network with EfficientNetV2-Small backbone
296
+ - **목적**: 이미지 쌍의 유사도 측정
297
+ - **출력**: 0-1 사이의 유사도 점수
298
+ - **손실 함수**: Focal Loss (α=0.25, γ=2.0)
 
299
 
300
+ ### 컴퓨팅 인프라
301
 
302
+ #### 하드웨어
303
 
304
+ - **GPU**: NVIDIA RTX 3080 (10GB VRAM)
305
+ - **CPU**: Intel i7-10700K
306
+ - **RAM**: 32GB DDR4
307
+ - **저장공간**: 1TB NVMe SSD
308
 
309
+ #### 소프트웨어
310
 
311
+ - **Python**: 3.9
312
+ - **PyTorch**: 1.12.0
313
+ - **ONNX Runtime**: 1.12.0
314
+ - **CUDA**: 11.6
315
+ - **기타**: timm, torchvision, PIL
316
 
317
+ ## 인용
318
 
319
+ 모델을 사용하시는 경우, 다음 형식으로 인용해 주세요:
 
 
 
 
 
 
 
 
320
 
321
  **BibTeX:**
322
+ ```bibtex
323
+ @misc{room_image_similarity_model,
324
+ title={Room Image Similarity Model: Siamese Network for Hotel Room Image Comparison},
325
+ author={Your Name},
326
+ year={2024},
327
+ howpublished={Hugging Face Model Hub},
328
+ url={https://huggingface.co/your-username/room-image-similarity}
329
+ }
330
+ ```
331
 
332
  **APA:**
333
+ ```
334
+ Your Name. (2024). Room Image Similarity Model: Siamese Network for Hotel Room Image Comparison. Hugging Face Model Hub. https://huggingface.co/your-username/room-image-similarity
335
+ ```
336
 
337
+ ## 용어집
 
 
338
 
339
+ - **Siamese Network**: 입력을 동일한 네트워크로 처리하여 유사도를 계산하는 신경망 구조
340
+ - **EfficientNetV2**: 효율적인 이미지 분류를 위한 CNN 아키텍처
341
+ - **Focal Loss**: 불균형 데이터셋에 최적화된 손실 함수
342
+ - **ImageNet 정규화**: ImageNet 데이터셋의 평균과 표준편차를 사용한 이미지 정규화
343
 
344
+ ## 추가 정보
345
 
346
+ - **프로젝트 저장소**: [GitHub Repository](https://github.com/your-username/content-ml-trainer)
347
+ - **문서**: [프로젝트 문서](https://github.com/your-username/content-ml-trainer/docs)
348
+ - **이슈 리포트**: [GitHub Issues](https://github.com/your-username/content-ml-trainer/issues)
349
 
350
+ ## 모델 카드 작성자
351
 
352
+ - **개발자**: Your Name
353
+ - **연락처**: your.email@example.com
354
+ - **소속**: Your Organization
355
 
356
+ ## 모델 카드 연락처
357
 
358
+ 모델에 대한 문의사항이나 문제가 있으시면 다음으로 연락해 주세요:
359
 
360
+ - **이메일**: your.email@example.com
361
+ - **GitHub**: [@your-username](https://github.com/your-username)
362
+ - **이슈**: [GitHub Issues](https://github.com/your-username/content-ml-trainer/issues)
similarity_model_0.6_inference_example.py → inference_example.py RENAMED
File without changes
similarity_model_0.6.onnx → model.onnx RENAMED
File without changes
similarity_model_0.6.pth → model.pth RENAMED
File without changes
similarity_model_0.6_model_info.json → model_info.json RENAMED
File without changes