Files changed (1) hide show
  1. app.py +0 -75
app.py DELETED
@@ -1,75 +0,0 @@
1
- import replicate
2
- import gradio as gr
3
- from io import BytesIO
4
- import base64
5
- import os
6
-
7
- illuse = replicate.Client(api_token=os.getenv('REPLICATE'))
8
- model_name = "andreasjansson/illusion:75d51a73fce3c00de31ed9ab4358c73e8fc0f627dc8ce975818e653317cb919b"
9
- example_image = "https://replicate.delivery/pbxt/hHJNV9QteKX8DK2ckkUeXsqbEIKNGFXU1fN0MJoizz3iPlOjA/output-0.png"
10
-
11
- 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):
12
- try:
13
- inputs = {
14
- 'prompt': prompt,
15
- 'negative_prompt': negative_prompt,
16
- 'qr_code_content': qr_content,
17
- 'num_inference_steps': num_inference_steps,
18
- 'guidance_scale': guidance_scale,
19
- 'width': width,
20
- 'height': height,
21
- 'seed': seed,
22
- 'num_outputs': num_outputs,
23
- 'controlnet_conditioning_scale': controlnet_conditioning_scale,
24
- 'border': border,
25
- 'qrcode_background': qrcode_background
26
- }
27
- if pattern_image is not None:
28
- inputs['image'] = open(pattern_image, 'rb')
29
-
30
- result = illuse.run(
31
- model_name,
32
- input=inputs
33
- )
34
- return result
35
- except Exception as e:
36
- print(e)
37
- gr.Error(str(e))
38
- return
39
-
40
-
41
- with gr.Blocks() as demo:
42
- gr.Markdown("""
43
- # Illusion Diffusion Fast demo
44
- ## powered by replicate
45
- """)
46
- with gr.Row():
47
- with gr.Column():
48
- prompt = gr.Textbox(label="Prompt")
49
- negative_prompt = gr.Textbox(label="Negative")
50
- with gr.Row():
51
- qr_content = gr.Textbox(label="QR Code Content", placeholder="https://youtube.com/")
52
- pattern_input = gr.Image(label="Pattern Image(if used QR Code Content wont be used)", type="filepath")
53
- with gr.Accordion("Additional Settings", open=False):
54
- with gr.Row():
55
- num_inference_steps = gr.Slider(label="num_inference_steps", minimum=20, maximum=100, step=1, value=50)
56
- guidance_scale = gr.Slider(label="guidance_scale", minimum=0.1, maximum=30, step=0.01, value=7.5)
57
- with gr.Row():
58
- width = gr.Slider(label='width', minimum=128, maximum=1024, step=8, value=768)
59
- height = gr.Slider(label='height', minimum=128, maximum=1024, step=8, value=768)
60
- with gr.Row():
61
- seed = gr.Number(label='seed', value=-1)
62
- num_outputs = gr.Slider(label="num_outputs", minimum=1, maximum=4, step=1)
63
- with gr.Row():
64
- controlnet_conditioning_scale = gr.Slider(label="controlnet_conditioning_scale", minimum=0, maximum=4, step=1, value=1)
65
- border = gr.Slider(label="border", minimum=0, maximum=4, step=1, value=4)
66
- qrcode_background = gr.Dropdown(label="qrcode_background", choices=['gray', 'white'], value='white')
67
- run_btn = gr.Button("Run", variant="primary")
68
- output = gr.Gallery([example_image])
69
-
70
- generation_event = run_btn.click(generate, inputs=[prompt, negative_prompt, qr_content, pattern_input,
71
- num_inference_steps, guidance_scale, width, height, seed,
72
- num_outputs, controlnet_conditioning_scale, border,
73
- qrcode_background], outputs=output)
74
-
75
- demo.launch(show_api=False)