Update app.py
Browse files
app.py
CHANGED
|
@@ -2,21 +2,24 @@ import gradio as gr
|
|
| 2 |
from diffusers import StableDiffusionPipeline
|
| 3 |
import torch
|
| 4 |
|
| 5 |
-
# Load model dari Hugging Face hub
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
def generate_image(prompt):
|
|
|
|
|
|
|
| 12 |
image = pipe(prompt).images[0]
|
|
|
|
| 13 |
return image
|
| 14 |
|
| 15 |
# Gradio UI
|
| 16 |
gr.Interface(
|
| 17 |
fn=generate_image,
|
| 18 |
-
inputs=gr.Textbox(label="Masukkan
|
| 19 |
outputs=gr.Image(label="Hasil Gambar Batik"),
|
| 20 |
-
title="Batik
|
| 21 |
-
description="Masukkan deskripsi motif batik, dan AI akan menghasilkan gambarnya!"
|
| 22 |
-
).launch()
|
|
|
|
| 2 |
from diffusers import StableDiffusionPipeline
|
| 3 |
import torch
|
| 4 |
|
| 5 |
+
# Load model dari Hugging Face hub untuk CPU
|
| 6 |
+
# Hapus torch_dtype=torch.float16 dan .to("cuda")
|
| 7 |
+
print("Memuat model ke CPU... proses ini mungkin butuh beberapa saat.")
|
| 8 |
+
pipe = StableDiffusionPipeline.from_pretrained("izzudd/sd-batik-llava")
|
| 9 |
+
print("Model berhasil dimuat!")
|
| 10 |
|
| 11 |
def generate_image(prompt):
|
| 12 |
+
print(f"Mulai menghasilkan gambar untuk prompt: '{prompt}'")
|
| 13 |
+
# Generate gambar di CPU
|
| 14 |
image = pipe(prompt).images[0]
|
| 15 |
+
print("Gambar berhasil dibuat!")
|
| 16 |
return image
|
| 17 |
|
| 18 |
# Gradio UI
|
| 19 |
gr.Interface(
|
| 20 |
fn=generate_image,
|
| 21 |
+
inputs=gr.Textbox(label="Masukkan Deskripsi Batik"),
|
| 22 |
outputs=gr.Image(label="Hasil Gambar Batik"),
|
| 23 |
+
title="Generator Batik AI (Versi CPU)",
|
| 24 |
+
description="Masukkan deskripsi motif batik, dan AI akan menghasilkan gambarnya! Harap bersabar, proses di CPU akan memakan waktu beberapa menit."
|
| 25 |
+
).launch()
|