aliceblue11 commited on
Commit
d147905
1 Parent(s): a1addd1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -8
app.py CHANGED
@@ -81,11 +81,27 @@ def generate_response(prompt, reference_text, max_tokens, temperature, top_p, mo
81
  return response_html
82
 
83
  def execute_action(image_file, font_file, selected_font, input1, input2, input3):
84
- # 여기에 추가적인 기능을 구현할 수 있습니다.
85
- # 현재는 단순히 입력값을 출력하는 예시입니다.
86
- output1 = f"업로드된 이미지 파일: {image_file.name if image_file else '없음'}"
87
- output2 = f"선택된 폰트: {selected_font if selected_font else '없음'}\n추가 입력1: {input1}\n추가 입력2: {input2}\n추가 입력3: {input3}"
88
- return output1, output2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
  # Gradio 인터페이스 설정
91
  with gr.Blocks() as demo:
@@ -109,10 +125,10 @@ with gr.Blocks() as demo:
109
  gr.Markdown("### 추가 기능")
110
 
111
  # 1. 이미지 파일 업로드
112
- image_upload = gr.File(label="파일 업로드", file_types=["image"], type="file")
113
 
114
  # 2. 폰트 파일 업로드
115
- font_upload = gr.File(label="폰트 파일 업로드", file_types=["font"], type="file")
116
 
117
  # 3. 업로드한 폰트 선택 드롭다운
118
  font_dropdown = gr.Dropdown(label="폰트 선택", choices=[], interactive=True)
@@ -133,7 +149,8 @@ with gr.Blocks() as demo:
133
  def update_font_dropdown(uploaded_font, current_choices):
134
  if uploaded_font:
135
  font_name = os.path.splitext(uploaded_font.name)[0]
136
- return current_choices + [font_name]
 
137
  return current_choices
138
 
139
  font_upload.change(
 
81
  return response_html
82
 
83
  def execute_action(image_file, font_file, selected_font, input1, input2, input3):
84
+ # 업로드된 이미지 파일 처리
85
+ if image_file:
86
+ image_info = f"업로드된 이미지 파일: {image_file.name}"
87
+ else:
88
+ image_info = "업로드된 이미지 파일: 없음"
89
+
90
+ # 업로드된 폰트 파일 처리
91
+ if font_file:
92
+ font_info = f"업로드된 폰트 파일: {font_file.name}"
93
+ else:
94
+ font_info = "업로드된 폰트 파일: 없음"
95
+
96
+ # 선택된 폰트와 추가 입력값 처리
97
+ if selected_font:
98
+ selected_font_info = f"선택된 폰트: {selected_font}"
99
+ else:
100
+ selected_font_info = "선택된 폰트: 없음"
101
+
102
+ additional_info = f"{selected_font_info}\n추가 입력1: {input1}\n추가 입력2: {input2}\n추가 입력3: {input3}"
103
+
104
+ return image_info, additional_info
105
 
106
  # Gradio 인터페이스 설정
107
  with gr.Blocks() as demo:
 
125
  gr.Markdown("### 추가 기능")
126
 
127
  # 1. 이미지 파일 업로드
128
+ image_upload = gr.File(label="파일 업로드", file_types=["image"], type="binary")
129
 
130
  # 2. 폰트 파일 업로드
131
+ font_upload = gr.File(label="폰트 파일 업로드", file_types=[".ttf", ".otf"], type="binary")
132
 
133
  # 3. 업로드한 폰트 선택 드롭다운
134
  font_dropdown = gr.Dropdown(label="폰트 선택", choices=[], interactive=True)
 
149
  def update_font_dropdown(uploaded_font, current_choices):
150
  if uploaded_font:
151
  font_name = os.path.splitext(uploaded_font.name)[0]
152
+ if font_name not in current_choices:
153
+ return current_choices + [font_name]
154
  return current_choices
155
 
156
  font_upload.change(