Spaces:
Configuration error
Configuration error
Initial Space setup of broadfield-dev/gradio-space via Builder
Browse files- README.md +8 -11
- config.json +5 -0
- main.py +19 -0
- requirements.txt +2 -0
README.md
CHANGED
@@ -1,12 +1,9 @@
|
|
1 |
-
|
2 |
-
title: Gradio Space
|
3 |
-
emoji: 🌖
|
4 |
-
colorFrom: yellow
|
5 |
-
colorTo: red
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 5.33.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
---
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Gradio Space: English to French Text Translator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
A simple Gradio app that translates English text to French text using the Hugging Face Transformers library.
|
4 |
+
|
5 |
+
## Usage
|
6 |
+
|
7 |
+
1. Install the required dependencies by running `pip install -r requirements.txt`
|
8 |
+
2. Run the app using `python main.py`
|
9 |
+
3. Open your web browser and navigate to `http://localhost:8000` to use the app
|
config.json
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"port": 8000
|
3 |
+
}
|
4 |
+
|
5 |
+
This project definition includes a README file with instructions on how to use the app, a main.py file that defines the app and its functionality, a requirements.txt file that specifies the required dependencies, and a config.json file that configures the app's port. The app uses the Hugging Face Transformers library to translate English text to French text and is deployed using Gradio.
|
main.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Import necessary libraries
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
+
import json
|
5 |
+
|
6 |
+
# Load the French translation pipeline
|
7 |
+
french_pipeline = pipeline("translation_en_to_fr")
|
8 |
+
|
9 |
+
# Define the app
|
10 |
+
def translate(text):
|
11 |
+
# Translate the input text using the pipeline
|
12 |
+
output = french_pipeline(text, max_length=50, truncation=True)
|
13 |
+
return output[0]['translation_text']
|
14 |
+
|
15 |
+
# Create the app interface
|
16 |
+
app = gr.Interface(fn=translate, inputs="text", outputs="text", title="English to French Text Translator")
|
17 |
+
|
18 |
+
# Launch the app
|
19 |
+
app.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
gradio
|