Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,15 +2,22 @@
|
|
2 |
|
3 |
from transformers import pipeline
|
4 |
import gradio as gr
|
5 |
-
from diffusers import DiffusionPipeline
|
6 |
-
from diffusers import FluxPipeline
|
7 |
import torch
|
8 |
import time
|
9 |
|
10 |
# Load models
|
11 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-dra-en")
|
12 |
summarizer = pipeline("summarization", model="Falconsai/text_summarization")
|
13 |
-
image_pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.float16).to("cpu")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
# Translate Tamil to English
|
@@ -28,10 +35,13 @@ def summarize_english_text(paragraph):
|
|
28 |
|
29 |
|
30 |
# Generate image from English text
|
31 |
-
def english_text_to_image(
|
32 |
-
|
|
|
|
|
|
|
33 |
return image
|
34 |
-
|
35 |
|
36 |
with gr.Blocks() as app:
|
37 |
gr.Markdown("# Multifunctional Gradio App")
|
|
|
2 |
|
3 |
from transformers import pipeline
|
4 |
import gradio as gr
|
5 |
+
# from diffusers import DiffusionPipeline
|
6 |
+
# from diffusers import FluxPipeline
|
7 |
import torch
|
8 |
import time
|
9 |
|
10 |
# Load models
|
11 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-dra-en")
|
12 |
summarizer = pipeline("summarization", model="Falconsai/text_summarization")
|
13 |
+
# image_pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.float16).to("cpu")
|
14 |
+
|
15 |
+
API_URL = "https://api-inference.huggingface.co/models/ZB-Tech/Text-to-Image"
|
16 |
+
headers = {"Authorization": f"Bearer {os.getenv('HF_API_TOKEN')}"}
|
17 |
+
|
18 |
+
def query(payload):
|
19 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
20 |
+
return response.content
|
21 |
|
22 |
|
23 |
# Translate Tamil to English
|
|
|
35 |
|
36 |
|
37 |
# Generate image from English text
|
38 |
+
def english_text_to_image(prompt):
|
39 |
+
image_bytes = query({
|
40 |
+
"inputs": prompt,
|
41 |
+
})
|
42 |
+
image = Image.open(io.BytesIO(image_bytes))
|
43 |
return image
|
44 |
+
|
45 |
|
46 |
with gr.Blocks() as app:
|
47 |
gr.Markdown("# Multifunctional Gradio App")
|