File size: 1,148 Bytes
452f26d 8457e18 452f26d 8e9bd69 4a3ead8 8e9bd69 4a3ead8 8e9bd69 0efb599 4a3ead8 0efb599 452f26d 8e9bd69 4a3ead8 8e9bd69 4a3ead8 8457e18 8e9bd69 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import gradio as gr
import os
def process_file(file_obj):
if file_obj is None:
return "No file uploaded."
# ํ์ผ ์ ์ฅํ๊ธฐ
save_path = os.path.join(os.getcwd(), file_obj.name)
with open(save_path, "wb") as f:
f.write(file_obj.read())
# ์ ๋ ๊ฒฝ๋ก ๋ฐํ
return save_path
def process_text(text):
# ์
๋ ฅ๋ ํ
์คํธ๋ฅผ ๊ทธ๋๋ก ๋ฐํ
return text
with gr.Blocks() as demo:
# ํ
์คํธ ์
๋ ฅ ๋ฐ ์ถ๋ ฅ ๋ธ๋ก
with gr.Group():
with gr.Row():
text_input = gr.Textbox(label="Enter Text Here")
submit_text_button = gr.Button("Submit Text")
text_output = gr.Text(label="Processed Text")
submit_text_button.click(process_text, inputs=text_input, outputs=text_output)
# ํ์ผ ์
๋ ฅ ๋ฐ ๊ฒฝ๋ก ์ถ๋ ฅ ๋ธ๋ก
with gr.Group():
with gr.Row():
file_input = gr.File(label="Drag & Drop File Here")
submit_file_button = gr.Button("Submit File")
file_output = gr.Text(label="File Path")
submit_file_button.click(process_file, inputs=file_input, outputs=file_output)
demo.launch()
|