Spaces:
Sleeping
Sleeping
Moibe
commited on
Commit
·
af7e87c
1
Parent(s):
86b77ec
Remove transformers
Browse files- .gitignore +1 -0
- app.py +25 -3
- envchk.py +8 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
venv/
|
app.py
CHANGED
@@ -2,15 +2,31 @@ import gradio as gr
|
|
2 |
|
3 |
from transformers import pipeline
|
4 |
|
5 |
-
pipe = pipeline("translation", model="t5-base")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
def translate(text):
|
8 |
-
return
|
9 |
|
10 |
with gr.Blocks() as demo:
|
11 |
with gr.Row():
|
12 |
with gr.Column():
|
13 |
english = gr.Textbox(label="English text")
|
|
|
|
|
14 |
translate_btn = gr.Button(value="Translate")
|
15 |
with gr.Column():
|
16 |
german = gr.Textbox(label="German Text")
|
@@ -19,4 +35,10 @@ with gr.Blocks() as demo:
|
|
19 |
examples = gr.Examples(examples=["I went to the supermarket yesterday.", "Helen is a good swimmer."],
|
20 |
inputs=[english])
|
21 |
|
22 |
-
demo.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
from transformers import pipeline
|
4 |
|
5 |
+
#pipe = pipeline("translation", model="t5-base")
|
6 |
+
|
7 |
+
get_local_storage = """
|
8 |
+
function() {
|
9 |
+
globalThis.setStorage = (key, value)=>{
|
10 |
+
localStorage.setItem(key, JSON.stringify(value))
|
11 |
+
}
|
12 |
+
globalThis.getStorage = (key, value)=>{
|
13 |
+
return JSON.parse(localStorage.getItem(key))
|
14 |
+
}
|
15 |
+
const text_input = getStorage('text_input')
|
16 |
+
return text_input;
|
17 |
+
}
|
18 |
+
"""
|
19 |
+
|
20 |
|
21 |
def translate(text):
|
22 |
+
return text
|
23 |
|
24 |
with gr.Blocks() as demo:
|
25 |
with gr.Row():
|
26 |
with gr.Column():
|
27 |
english = gr.Textbox(label="English text")
|
28 |
+
text_input = gr.Text(label="Input va allá")
|
29 |
+
text_input.change(None, text_input, None, _js="(v)=>{ setStorage('text_input',v) }")
|
30 |
translate_btn = gr.Button(value="Translate")
|
31 |
with gr.Column():
|
32 |
german = gr.Textbox(label="German Text")
|
|
|
35 |
examples = gr.Examples(examples=["I went to the supermarket yesterday.", "Helen is a good swimmer."],
|
36 |
inputs=[english])
|
37 |
|
38 |
+
demo.load(
|
39 |
+
None,
|
40 |
+
inputs=None,
|
41 |
+
outputs=text_input,
|
42 |
+
_js=get_local_storage,
|
43 |
+
)
|
44 |
+
demo.launch(debug=True)
|
envchk.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
|
4 |
+
if os.getenv('VIRTUAL_ENV'):
|
5 |
+
env_name = os.path.basename(sys.prefix)
|
6 |
+
print(f"Estás dentro del entorno virtual: {env_name}")
|
7 |
+
else:
|
8 |
+
print("No estás dentro de un entorno virtual.")
|