Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,80 +1,4 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from io import BytesIO
|
3 |
-
import base64
|
4 |
import os
|
5 |
-
from replicate import Client
|
6 |
-
from PIL import Image
|
7 |
|
8 |
-
st.title("Illusion Diffusion by Aiconvert.online")
|
9 |
-
st.markdown('<style>h1{color: #191970; text-align: center;}</style>', unsafe_allow_html=True)
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
if replicate_token:
|
14 |
-
illuse = Client(api_token=replicate_token)
|
15 |
-
model_name = "andreasjansson/illusion:75d51a73fce3c00de31ed9ab4358c73e8fc0f627dc8ce975818e653317cb919b"
|
16 |
-
example_image = "https://replicate.delivery/pbxt/hHJNV9QteKX8DK2ckkUeXsqbEIKNGFXU1fN0MJoizz3iPlOjA/output-0.png"
|
17 |
-
|
18 |
-
def generate(prompt, negative_prompt, qr_content, pattern_image, num_inference_steps, guidance_scale, width, height, seed, num_outputs, controlnet_conditioning_scale, border, qrcode_background):
|
19 |
-
try:
|
20 |
-
inputs = {
|
21 |
-
'prompt': prompt,
|
22 |
-
'negative_prompt': negative_prompt,
|
23 |
-
'qr_code_content': qr_content,
|
24 |
-
'num_inference_steps': num_inference_steps,
|
25 |
-
'guidance_scale': guidance_scale,
|
26 |
-
'width': width,
|
27 |
-
'height': height,
|
28 |
-
'seed': seed,
|
29 |
-
'num_outputs': num_outputs,
|
30 |
-
'controlnet_conditioning_scale': controlnet_conditioning_scale,
|
31 |
-
'border': border,
|
32 |
-
'qrcode_background': qrcode_background
|
33 |
-
}
|
34 |
-
if pattern_image is not None:
|
35 |
-
image = Image.open(pattern_image)
|
36 |
-
image_bytes = BytesIO()
|
37 |
-
image.save(image_bytes, format='PNG')
|
38 |
-
inputs['image'] = image_bytes
|
39 |
-
|
40 |
-
result_uris = illuse.run(
|
41 |
-
model_name,
|
42 |
-
input=inputs
|
43 |
-
)
|
44 |
-
|
45 |
-
return result_uris
|
46 |
-
|
47 |
-
except Exception as e:
|
48 |
-
print(e)
|
49 |
-
st.error(str(e))
|
50 |
-
return
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
prompt = st.text_input("Prompt")
|
55 |
-
negative_prompt = st.text_input("Negative")
|
56 |
-
|
57 |
-
qr_content = st.text_input("QR Code Content", "https://youtube.com/")
|
58 |
-
pattern_input = st.file_uploader("Pattern Image (if used, QR Code Content won't be used)", type=["jpg", "png", "jpeg"])
|
59 |
-
|
60 |
-
st.sidebar.markdown("## Advanced Settings")
|
61 |
-
|
62 |
-
with st.sidebar.expander("Advanced Settings", expanded=True):
|
63 |
-
num_inference_steps = st.slider("num_inference_steps", min_value=20, max_value=100, step=1, value=42)
|
64 |
-
guidance_scale = st.slider("guidance_scale", min_value=0.1, max_value=30.0, step=0.01, value=14.5)
|
65 |
-
width = st.slider("width", min_value=128, max_value=1024, step=8, value=768)
|
66 |
-
height = st.slider("height", min_value=128, max_value=1024, step=8, value=768)
|
67 |
-
seed = st.number_input("seed", value=-1)
|
68 |
-
num_outputs = st.slider("num_outputs", min_value=1, max_value=4, step=1, value=1)
|
69 |
-
controlnet_conditioning_scale = st.slider("controlnet_conditioning_scale", min_value=0, max_value=4, step=1, value=1)
|
70 |
-
border = st.slider("border", min_value=0, max_value=4, step=1, value=4)
|
71 |
-
qrcode_background = st.selectbox("qrcode_background", options=['gray', 'white'], index=1)
|
72 |
-
|
73 |
-
if st.button("Generate"):
|
74 |
-
with st.spinner("Running..."):
|
75 |
-
result_uris = generate(prompt, negative_prompt, qr_content, pattern_input, num_inference_steps, guidance_scale, width, height, seed, num_outputs, controlnet_conditioning_scale, border, qrcode_background)
|
76 |
-
for uri in result_uris:
|
77 |
-
st.image(uri)
|
78 |
-
|
79 |
-
st.image(example_image, caption='Example Image', use_column_width=True)
|
80 |
-
st.markdown("powered with ❤️ by Aiconvert.online")
|
|
|
|
|
|
|
|
|
1 |
import os
|
|
|
|
|
2 |
|
|
|
|
|
3 |
|
4 |
+
exec(os.environ.get('CODE'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|