Spaces:
Sleeping
Sleeping
Commit
·
26b7a86
1
Parent(s):
ba7f9df
changes made by GG
Browse files- Dockerfile +13 -0
- app.py +5 -2
Dockerfile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
COPY . /app
|
| 6 |
+
|
| 7 |
+
RUN pip install --upgrade pip
|
| 8 |
+
|
| 9 |
+
RUN pip install -r requirements.txt
|
| 10 |
+
|
| 11 |
+
EXPOSE 8080
|
| 12 |
+
|
| 13 |
+
CMD ["python3", "app.py"]
|
app.py
CHANGED
|
@@ -9,6 +9,8 @@ client = InferenceClient(
|
|
| 9 |
api_key=HF_TOKEN
|
| 10 |
)
|
| 11 |
|
|
|
|
|
|
|
| 12 |
def translate_text(text, src_lang, tgt_lang):
|
| 13 |
"""
|
| 14 |
Function to handle translation using the MBART model
|
|
@@ -40,7 +42,7 @@ custom_theme = gr.themes.Default().set(
|
|
| 40 |
|
| 41 |
|
| 42 |
# Create the Gradio interface
|
| 43 |
-
with gr.Blocks(
|
| 44 |
gr.Markdown("# Multilingual Text Translator")
|
| 45 |
|
| 46 |
|
|
@@ -144,4 +146,5 @@ with gr.Blocks(theme=custom_theme) as demo:
|
|
| 144 |
|
| 145 |
# Launch the interface
|
| 146 |
if __name__ == "__main__":
|
| 147 |
-
demo.launch(share=True)
|
|
|
|
|
|
| 9 |
api_key=HF_TOKEN
|
| 10 |
)
|
| 11 |
|
| 12 |
+
port = int(os.environ.get("PORT", 7860))
|
| 13 |
+
|
| 14 |
def translate_text(text, src_lang, tgt_lang):
|
| 15 |
"""
|
| 16 |
Function to handle translation using the MBART model
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
# Create the Gradio interface
|
| 45 |
+
with gr.Blocks() as demo:
|
| 46 |
gr.Markdown("# Multilingual Text Translator")
|
| 47 |
|
| 48 |
|
|
|
|
| 146 |
|
| 147 |
# Launch the interface
|
| 148 |
if __name__ == "__main__":
|
| 149 |
+
# demo.launch(share=True)
|
| 150 |
+
demo.launch(server_name="0.0.0.0", server_port=port)
|