Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,23 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
def process_text(text):
|
| 4 |
return text
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
demo = gr.Interface(
|
| 7 |
-
process_text,
|
| 8 |
-
gr.Textbox(placeholder="Enter sentence here..."),
|
| 9 |
-
["
|
|
|
|
| 10 |
)
|
| 11 |
|
| 12 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
|
| 4 |
def process_text(text):
|
| 5 |
return text
|
| 6 |
|
| 7 |
+
def process_file(file_info):
|
| 8 |
+
if file_info is None:
|
| 9 |
+
return "No file uploaded."
|
| 10 |
+
filepath, filename = file_info
|
| 11 |
+
save_path = os.path.join(os.getcwd(), filename)
|
| 12 |
+
os.rename(filepath, save_path)
|
| 13 |
+
return save_path
|
| 14 |
+
|
| 15 |
+
|
| 16 |
demo = gr.Interface(
|
| 17 |
+
fn=[process_text, process_file],
|
| 18 |
+
inputs=[gr.Textbox(placeholder="Enter sentence here..."), gr.File(label="Drag & Drop File Here")],
|
| 19 |
+
outputs=["text", "text"],
|
| 20 |
+
descriptions=["Enter a sentence to process.", "Upload a file to see its absolute path."]
|
| 21 |
)
|
| 22 |
|
| 23 |
+
demo.launch()
|