salehalmansour commited on
Commit
3b9c5f8
1 Parent(s): 616caeb

Delete app.py

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