Update app.py
Browse files
app.py
CHANGED
@@ -151,31 +151,7 @@ def process_image(image, brightness, contrast, saturation, temperature, tint, ex
|
|
151 |
|
152 |
# PIL 이미지로 다시 변환
|
153 |
return Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
|
154 |
-
|
155 |
-
def download_image(image, input_image_name):
|
156 |
-
"""이미지를 JPG 형식으로 저장하고 경로 반환"""
|
157 |
-
if image is None:
|
158 |
-
return None
|
159 |
-
|
160 |
-
# 한국 시간 타임스탬프 생성
|
161 |
-
def get_korean_timestamp():
|
162 |
-
korea_time = datetime.utcnow() + timedelta(hours=9)
|
163 |
-
return korea_time.strftime('%Y%m%d_%H%M%S')
|
164 |
-
|
165 |
-
timestamp = get_korean_timestamp()
|
166 |
-
if input_image_name and hasattr(input_image_name, 'name'):
|
167 |
-
base_name = input_image_name.name.split('.')[0] # 파일 객체에서 이름 추출
|
168 |
-
else:
|
169 |
-
base_name = "이미지"
|
170 |
-
|
171 |
-
file_name = f"[끝장AI]끝장필터_{base_name}_{timestamp}.jpg"
|
172 |
-
|
173 |
-
# 파일 저장
|
174 |
-
temp_file_path = tempfile.gettempdir() + "/" + file_name
|
175 |
-
image.save(temp_file_path, format="JPEG")
|
176 |
-
return temp_file_path
|
177 |
-
|
178 |
-
|
179 |
|
180 |
def translate_prompt_to_english(prompt):
|
181 |
# 기존 함수 유지
|
@@ -1190,10 +1166,10 @@ with gr.Blocks(css=custom_css) as demo:
|
|
1190 |
with gr.TabItem("🖌️ 이미지 필터", elem_classes="tab-content"):
|
1191 |
with gr.Row(equal_height=True):
|
1192 |
# 왼쪽 열: 비율 3
|
1193 |
-
with gr.Column(scale=
|
1194 |
gr.HTML('<div class="section-title"><i class="fas fa-sliders-h"></i> 이미지 필터 설정</div>')
|
1195 |
# 이미지 업로드
|
1196 |
-
filter_input_image = gr.Image(type="pil", label="이미지 업로드", elem_classes="image-container", height=
|
1197 |
|
1198 |
# 조정 슬라이더
|
1199 |
with gr.Group():
|
@@ -1207,16 +1183,11 @@ with gr.Blocks(css=custom_css) as demo:
|
|
1207 |
color_mixer_blues_slider = gr.Slider(-100.0, 100.0, value=0.0, step=1.0, label="컬러 믹서 (블루)")
|
1208 |
shadows_slider = gr.Slider(-100.0, 100.0, value=0.0, step=1.0, label="그림자 조절")
|
1209 |
|
1210 |
-
# 오른쪽 열:
|
1211 |
-
with gr.Column(scale=
|
1212 |
gr.HTML('<div class="section-title"><i class="fas fa-image"></i> 필터 적용 결과</div>')
|
1213 |
# 처리된 이미지 출력 - 높이를 입력 이미지와 동일하게 설정
|
1214 |
-
filter_output_image = gr.Image(type="pil", label="처리된 이미지", elem_classes="image-container", height=
|
1215 |
-
|
1216 |
-
# 다운로드 버튼 - "결과이미지저장" 섹션으로 변경하고 파일 다운로드를 그 아래에 배치
|
1217 |
-
gr.HTML('<div class="section-title"><i class="fas fa-download"></i> 결과이미지저장</div>')
|
1218 |
-
download_button = gr.Button("결과이미지저장", elem_classes="custom-button primary")
|
1219 |
-
download_output = gr.File(label="JPG 이미지 다운로드")
|
1220 |
|
1221 |
# 이미지 처리 함수 연결
|
1222 |
inputs = [
|
|
|
151 |
|
152 |
# PIL 이미지로 다시 변환
|
153 |
return Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
|
154 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
def translate_prompt_to_english(prompt):
|
157 |
# 기존 함수 유지
|
|
|
1166 |
with gr.TabItem("🖌️ 이미지 필터", elem_classes="tab-content"):
|
1167 |
with gr.Row(equal_height=True):
|
1168 |
# 왼쪽 열: 비율 3
|
1169 |
+
with gr.Column(scale=1, elem_classes="panel"):
|
1170 |
gr.HTML('<div class="section-title"><i class="fas fa-sliders-h"></i> 이미지 필터 설정</div>')
|
1171 |
# 이미지 업로드
|
1172 |
+
filter_input_image = gr.Image(type="pil", label="이미지 업로드", elem_classes="image-container", height=500)
|
1173 |
|
1174 |
# 조정 슬라이더
|
1175 |
with gr.Group():
|
|
|
1183 |
color_mixer_blues_slider = gr.Slider(-100.0, 100.0, value=0.0, step=1.0, label="컬러 믹서 (블루)")
|
1184 |
shadows_slider = gr.Slider(-100.0, 100.0, value=0.0, step=1.0, label="그림자 조절")
|
1185 |
|
1186 |
+
# 오른쪽 열: 처리된 이미지
|
1187 |
+
with gr.Column(scale=1, elem_classes="panel"):
|
1188 |
gr.HTML('<div class="section-title"><i class="fas fa-image"></i> 필터 적용 결과</div>')
|
1189 |
# 처리된 이미지 출력 - 높이를 입력 이미지와 동일하게 설정
|
1190 |
+
filter_output_image = gr.Image(type="pil", label="처리된 이미지", elem_classes="image-container", height=500)
|
|
|
|
|
|
|
|
|
|
|
1191 |
|
1192 |
# 이미지 처리 함수 연결
|
1193 |
inputs = [
|