DmitrMakeev commited on
Commit
0677d40
0 Parent(s):

Duplicate from DmitryMakik/vk_Stable_Diffusion

Browse files
Files changed (4) hide show
  1. .gitattributes +35 -0
  2. README.md +14 -0
  3. app.py +35 -0
  4. requirements.txt +6 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Vk Stable Diffusion
3
+ emoji: 🐢
4
+ colorFrom: purple
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 3.23.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ duplicated_from: DmitryMakik/vk_Stable_Diffusion
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import modin.pandas as pd
3
+ import torch
4
+ import numpy as np
5
+ from PIL import Image
6
+ from diffusers import DiffusionPipeline
7
+ from huggingface_hub import login
8
+ #import os
9
+ #login(token=os.environ.get('HF_KEY'))
10
+ device = "cuda" if torch.cuda.is_available() else "cpu"
11
+ pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0")
12
+ pipe = pipe.to(device)
13
+ def resize(height, width, img):
14
+ img = Image.open(img)
15
+ img = img.resize((height, width))
16
+ return img
17
+ def infer(source_img, prompt, negative_prompt, height, width, guide, steps, seed, strength):
18
+ generator = torch.Generator(device).manual_seed(seed)
19
+ source_image = resize(height, width, source_img)
20
+ source_image.save('source.png')
21
+ image = pipe(prompt, negative_prompt=negative_prompt, image=source_image, strength=strength, guidance_scale=guide, num_inference_steps=steps).images[0]
22
+ return image
23
+ gr.Interface(fn=infer, inputs=[
24
+ gr.Image(source="upload", type="filepath", label="Raw Image. Must Be .png"),
25
+ gr.Textbox(label='Что вы хотите, чтобы ИИ генерировал'),
26
+ gr.Textbox(label='Что вы не хотите, чтобы ИИ генерировал'),
27
+ gr.Slider(512, 1024, 768, step=1, label='Ширина картинки'),
28
+ gr.Slider(512, 1024, 768, step=1, label='Высота картинки'),
29
+ gr.Slider(2, 15, value=7, label='Шкала навигации'),
30
+ gr.Slider(1, 25, value=10, step=1, label='Количество итераций'),
31
+ gr.Slider(label="Зерно", minimum=0, maximum=987654321987654321, step=1, randomize=True),
32
+ gr.Slider(label='Сила', minimum=0, maximum=1, step=.05, value=.5),
33
+
34
+ ],
35
+ outputs='image', title = "ВКонтакте - Stable Diffusion XL 1.0 - img2img",article = "<br><br><br><br><br>").launch(debug=True, max_threads=80)
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ diffusers
2
+ transformers
3
+ accelerate
4
+ ftfy
5
+ modin[all]
6
+ invisible_watermark