Davit12 commited on
Commit
38f93a0
·
verified ·
1 Parent(s): f7b8b80

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +13 -0
  2. all_models.py +27 -0
  3. app.py +85 -0
  4. requirements.txt +6 -0
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Image_Gen
3
+ emoji: 🚀
4
+ colorFrom: pink
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: 3.47.0
8
+ app_file: app.py
9
+ pinned: true
10
+ short_description: generates 32multi/ 16single images
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
all_models.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ models = [
2
+ "black-forest-labs/FLUX.1-dev",
3
+ "black-forest-labs/FLUX.1-schnell",
4
+ "XLabs-AI/flux-RealismLora",
5
+ "prithivMLmods/SD3.5-Turbo-Realism-2.0-LoRA",
6
+ "xey/sldr_flux_nsfw_v2-studio",
7
+ "aleksa-codes/flux-ghibsky-illustration",
8
+ "dataautogpt3/FLUX-SyntheticAnime",
9
+ "Shakker-Labs/FLUX.1-dev-LoRA-add-details",
10
+ "Shakker-Labs/FLUX.1-dev-LoRA-AntiBlur",
11
+ "brushpenbob/flux-midjourney-anime",
12
+ "stabilityai/stable-diffusion-3.5-large",
13
+ "stabilityai/stable-diffusion-3.5-large-turbo",
14
+ "stabilityai/stable-diffusion-xl-base-1.0",
15
+ "Yntec/epiCPhotoGasm",
16
+ #"dataautogpt3/ProteusV0.2",
17
+ "dataautogpt3/OpenDalleV1.1",
18
+ "falanaja/Amateur-Photography",
19
+ "lexa862/NSFWmodel",
20
+ "Keltezaa/ShowerGirls",
21
+ "pimpilikipilapi1/fltax",
22
+ "Jonny001/Alita-v1",
23
+ "Jonny001/EXD-v1",
24
+ "Jonny001/NSFW_master",
25
+ "aifeifei798/sldr_flux_nsfw_v2-studio",
26
+ "getad72493/innipssy",
27
+ ]
app.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from random import randint
3
+ from all_models import models
4
+
5
+ def load_fn(models):
6
+ global models_load
7
+ models_load = {}
8
+
9
+ for model in models:
10
+ if model not in models_load.keys():
11
+ try:
12
+ m = gr.load(f'models/{model}')
13
+ except Exception as error:
14
+ m = gr.Interface(lambda txt: None, ['text'], ['image'])
15
+ models_load.update({model: m})
16
+
17
+
18
+ load_fn(models)
19
+
20
+
21
+ num_models = 32
22
+ default_models = models[:num_models]
23
+
24
+
25
+ def extend_choices(choices):
26
+ return choices + (num_models - len(choices)) * ['NA']
27
+
28
+
29
+ def update_imgbox(choices):
30
+ choices_plus = extend_choices(choices)
31
+ return [gr.Image(None, label = m, visible = (m != 'NA')) for m in choices_plus]
32
+
33
+
34
+ def gen_fn(model_str, prompt):
35
+ if model_str == 'NA':
36
+ return None
37
+ noise = str(randint(0, 99999999999))
38
+ return models_load[model_str](f'{prompt} {noise}')
39
+
40
+
41
+ with gr.Blocks() as demo:
42
+ with gr.Tab('Multiple models'):
43
+ with gr.Accordion('Model selection'):
44
+ model_choice = gr.CheckboxGroup(models, label = f'Choose up to {num_models} different models', value = default_models, multiselect = True, max_choices = num_models, interactive = True, filterable = False)
45
+
46
+
47
+ txt_input = gr.Textbox(label = 'Prompt text')
48
+ gen_button = gr.Button('Generate')
49
+ stop_button = gr.Button('Stop', variant = 'secondary', interactive = False)
50
+ gen_button.click(lambda s: gr.update(interactive = True), None, stop_button)
51
+
52
+ with gr.Row():
53
+ output = [gr.Image(label = m) for m in default_models]
54
+ current_models = [gr.Textbox(m, visible = False) for m in default_models]
55
+
56
+ model_choice.change(update_imgbox, model_choice, output)
57
+ model_choice.change(extend_choices, model_choice, current_models)
58
+
59
+ for m, o in zip(current_models, output):
60
+ gen_event = gen_button.click(gen_fn, [m, txt_input], o, queue=False)
61
+
62
+
63
+ with gr.Tab('Single model'):
64
+ model_choice2 = gr.Dropdown(models, label = 'Choose model', value = models[0], filterable = False)
65
+ txt_input2 = gr.Textbox(label = 'Prompt text')
66
+
67
+ max_images = 16
68
+ num_images = gr.Slider(1, max_images, value = max_images, step = 1, label = 'Number of images')
69
+
70
+ gen_button2 = gr.Button('Generate')
71
+ stop_button2 = gr.Button('Stop', variant = 'secondary', interactive = False)
72
+ gen_button2.click(lambda s: gr.update(interactive = True), None, stop_button2)
73
+
74
+ with gr.Row():
75
+ output2 = [gr.Image(label = '') for _ in range(max_images)]
76
+
77
+ for i, o in enumerate(output2):
78
+ img_i = gr.Number(i, visible = False)
79
+ num_images.change(lambda i, n: gr.update(visible = (i < n)), [img_i, num_images], o)
80
+ gen_event2 = gen_button2.click(lambda i, n, m, t: gen_fn(m, t) if (i < n) else None, [img_i, num_images, model_choice2, txt_input2], o)
81
+ stop_button2.click(lambda s: gr.update(interactive = False), None, stop_button2, cancels = [gen_event2])
82
+
83
+
84
+ demo.queue(concurrency_count = 36)
85
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ accelerate
2
+ diffusers
3
+ invisible_watermark
4
+ torch
5
+ transformers
6
+ xformers