Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,24 @@
|
|
1 |
-
import
|
2 |
-
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
-
import gradio as gr
|
4 |
|
5 |
-
|
6 |
-
model_name = "machinelearningzuu/sinhala-text-to-speech"
|
7 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
-
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
9 |
|
10 |
-
def
|
11 |
-
inputs = tokenizer(text, return_tensors="pt")
|
12 |
-
with torch.no_grad():
|
13 |
-
outputs = model.generate(**inputs)
|
14 |
-
audio = outputs[0].cpu().numpy()
|
15 |
-
return audio
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
iface.launch()
|
|
|
1 |
+
import gradio as gr from PIL import Image from rembg import remove
|
|
|
|
|
2 |
|
3 |
+
def remove_background(image: Image.Image) -> Image.Image: output = remove(image) return output
|
|
|
|
|
|
|
4 |
|
5 |
+
def enhance_image(image: Image.Image) -> Image.Image: # Simple enhancement: convert to RGB and resize (2x upscale) image = image.convert("RGB") image = image.resize((image.width * 2, image.height * 2)) return image
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
with gr.Blocks() as demo: gr.Markdown("# \U0001f9e0 Samsung AI Style Photo Editor") gr.Markdown("Remove background, upscale, and prepare for generative edits using AI.")
|
8 |
+
|
9 |
+
with gr.Tab("\U0001f9fd Remove Background"):
|
10 |
+
with gr.Row():
|
11 |
+
input_image = gr.Image(type="pil", label="Upload Image")
|
12 |
+
output_image = gr.Image(label="Output Image")
|
13 |
+
remove_btn = gr.Button("Remove Background")
|
14 |
+
remove_btn.click(remove_background, inputs=input_image, outputs=output_image)
|
15 |
+
|
16 |
+
with gr.Tab("\U0001f50d Enhance Image"):
|
17 |
+
with gr.Row():
|
18 |
+
enhance_input = gr.Image(type="pil", label="Upload Image")
|
19 |
+
enhance_output = gr.Image(label="Enhanced Image")
|
20 |
+
enhance_btn = gr.Button("Enhance")
|
21 |
+
enhance_btn.click(enhance_image, inputs=enhance_input, outputs=enhance_output)
|
22 |
+
|
23 |
+
demo.launch()
|
24 |
|
|