Spaces:
No application file
No application file
File size: 1,130 Bytes
1b2d0b3 16f3792 c11f1e4 1b2d0b3 c11f1e4 1b2d0b3 c11f1e4 1b2d0b3 0adca5e 1b2d0b3 0adca5e 1b2d0b3 0adca5e 1b2d0b3 0adca5e 1b2d0b3 0adca5e 1b2d0b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
### App
### This code for app.py
class CFG:
device = "cpu"
seed = 42
generator = torch.Generator(device).manual_seed(seed)
image_gen_steps = 35
image_gen_model_id = "stabilityai/stable-diffusion-2"
image_gen_size = (400, 400)
image_gen_guidance_scale = 9
image_gen_model = StableDiffusionPipeline.from_pretrained(
CFG.image_gen_model_id, torch_dtype=torch.float32,
revision="fp16", use_auth_token='hf_pxvzpoafqjfkELFKMLTESNpvmyvkTVuD01', guidance_scale=9
)
apply = image_gen_model.to(CFG.device)
def generate_image(prompt):
## add translation model here before apply
image = apply(
prompt, num_inference_steps=CFG.image_gen_steps,
generator=CFG.generator,
guidance_scale=CFG.image_gen_guidance_scale
).images[0]
image = image.resize(CFG.image_gen_size)
return image
title = "نموذج توليد الصور"
description = " اكتب وصف للصورة التي تود من النظام التوليدي انشاءها"
iface = gr.Interface(fn=generate_image, inputs="text", outputs="image", title=title, description=description)
iface.launch() |