Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,18 @@ import streamlit as st
|
|
2 |
from gradio_client import Client
|
3 |
import time
|
4 |
import concurrent.futures
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
class ModelGenerator:
|
7 |
@staticmethod
|
8 |
def generate_midjourney(prompt):
|
9 |
try:
|
10 |
-
client = Client("mukaist/Midjourney")
|
11 |
result = client.predict(
|
12 |
prompt=prompt,
|
13 |
negative_prompt="(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck",
|
@@ -27,7 +33,7 @@ class ModelGenerator:
|
|
27 |
@staticmethod
|
28 |
def generate_stable_cascade(prompt):
|
29 |
try:
|
30 |
-
client = Client("multimodalart/stable-cascade")
|
31 |
result = client.predict(
|
32 |
prompt=prompt,
|
33 |
negative_prompt=prompt,
|
@@ -48,7 +54,7 @@ class ModelGenerator:
|
|
48 |
@staticmethod
|
49 |
def generate_stable_diffusion_3(prompt):
|
50 |
try:
|
51 |
-
client = Client("stabilityai/stable-diffusion-3-medium")
|
52 |
result = client.predict(
|
53 |
prompt=prompt,
|
54 |
negative_prompt=prompt,
|
@@ -67,7 +73,7 @@ class ModelGenerator:
|
|
67 |
@staticmethod
|
68 |
def generate_stable_diffusion_35(prompt):
|
69 |
try:
|
70 |
-
client = Client("stabilityai/stable-diffusion-3.5-large")
|
71 |
result = client.predict(
|
72 |
prompt=prompt,
|
73 |
negative_prompt=prompt,
|
@@ -86,7 +92,7 @@ class ModelGenerator:
|
|
86 |
@staticmethod
|
87 |
def generate_playground_v2_5(prompt):
|
88 |
try:
|
89 |
-
client = Client("https://playgroundai-playground-v2-5.hf.space/--replicas/ji5gy/")
|
90 |
result = client.predict(
|
91 |
prompt,
|
92 |
prompt, # negative prompt
|
@@ -127,6 +133,10 @@ def generate_images(prompt, selected_models):
|
|
127 |
return results
|
128 |
|
129 |
def handle_prompt_click(prompt_text, key):
|
|
|
|
|
|
|
|
|
130 |
st.session_state[f'selected_prompt_{key}'] = prompt_text
|
131 |
|
132 |
selected_models = st.session_state.get('selected_models', [])
|
@@ -144,6 +154,15 @@ def main():
|
|
144 |
st.title("🎨 Multi-Model Art Generator")
|
145 |
|
146 |
with st.sidebar:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
st.header("Model Selection")
|
148 |
st.session_state['selected_models'] = st.multiselect(
|
149 |
"Choose AI Models",
|
|
|
2 |
from gradio_client import Client
|
3 |
import time
|
4 |
import concurrent.futures
|
5 |
+
import os
|
6 |
+
|
7 |
+
# Get token from environment variable
|
8 |
+
HF_TOKEN = os.getenv('ArtToken')
|
9 |
+
if not HF_TOKEN:
|
10 |
+
raise ValueError("Please set the 'ArtToken' environment variable with your Hugging Face token")
|
11 |
|
12 |
class ModelGenerator:
|
13 |
@staticmethod
|
14 |
def generate_midjourney(prompt):
|
15 |
try:
|
16 |
+
client = Client("mukaist/Midjourney", hf_token=HF_TOKEN)
|
17 |
result = client.predict(
|
18 |
prompt=prompt,
|
19 |
negative_prompt="(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck",
|
|
|
33 |
@staticmethod
|
34 |
def generate_stable_cascade(prompt):
|
35 |
try:
|
36 |
+
client = Client("multimodalart/stable-cascade", hf_token=HF_TOKEN)
|
37 |
result = client.predict(
|
38 |
prompt=prompt,
|
39 |
negative_prompt=prompt,
|
|
|
54 |
@staticmethod
|
55 |
def generate_stable_diffusion_3(prompt):
|
56 |
try:
|
57 |
+
client = Client("stabilityai/stable-diffusion-3-medium", hf_token=HF_TOKEN)
|
58 |
result = client.predict(
|
59 |
prompt=prompt,
|
60 |
negative_prompt=prompt,
|
|
|
73 |
@staticmethod
|
74 |
def generate_stable_diffusion_35(prompt):
|
75 |
try:
|
76 |
+
client = Client("stabilityai/stable-diffusion-3.5-large", hf_token=HF_TOKEN)
|
77 |
result = client.predict(
|
78 |
prompt=prompt,
|
79 |
negative_prompt=prompt,
|
|
|
92 |
@staticmethod
|
93 |
def generate_playground_v2_5(prompt):
|
94 |
try:
|
95 |
+
client = Client("https://playgroundai-playground-v2-5.hf.space/--replicas/ji5gy/", hf_token=HF_TOKEN)
|
96 |
result = client.predict(
|
97 |
prompt,
|
98 |
prompt, # negative prompt
|
|
|
133 |
return results
|
134 |
|
135 |
def handle_prompt_click(prompt_text, key):
|
136 |
+
if not HF_TOKEN:
|
137 |
+
st.error("Environment variable 'ArtToken' is not set!")
|
138 |
+
return
|
139 |
+
|
140 |
st.session_state[f'selected_prompt_{key}'] = prompt_text
|
141 |
|
142 |
selected_models = st.session_state.get('selected_models', [])
|
|
|
154 |
st.title("🎨 Multi-Model Art Generator")
|
155 |
|
156 |
with st.sidebar:
|
157 |
+
st.header("Configuration")
|
158 |
+
|
159 |
+
# Show token status
|
160 |
+
if HF_TOKEN:
|
161 |
+
st.success("✓ ArtToken loaded from environment")
|
162 |
+
else:
|
163 |
+
st.error("⚠ ArtToken not found in environment")
|
164 |
+
|
165 |
+
st.markdown("---")
|
166 |
st.header("Model Selection")
|
167 |
st.session_state['selected_models'] = st.multiselect(
|
168 |
"Choose AI Models",
|