turboedit commited on
Commit
053ae38
โ€ข
1 Parent(s): 849c21d

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +62 -79
app.py CHANGED
@@ -8,64 +8,55 @@ import torch
8
  from my_run import run as run_model
9
 
10
 
11
- DESCRIPTION = '''# Turbo Edit
12
- '''
 
13
 
14
  @spaces.GPU
15
  def main_pipeline(
16
- input_image: str,
17
- src_prompt: str,
18
- tgt_prompt: str,
19
- seed: int,
20
- w1: float,
21
- # w2: float,
22
- ):
23
 
24
- w2 = 1.0
25
- res_image = run_model(input_image, src_prompt, tgt_prompt, seed, w1, w2)
26
 
27
- return res_image
28
 
29
 
30
- with gr.Blocks(css='app/style.css') as demo:
31
  gr.Markdown(DESCRIPTION)
32
 
33
  gr.HTML(
34
- '''<a href="https://huggingface.co/spaces/garibida/ReNoise-Inversion?duplicate=true">
35
- <img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>Duplicate the Space to run privately without waiting in queue''')
 
36
 
37
  with gr.Row():
38
  with gr.Column():
39
  input_image = gr.Image(
40
- label="Input image",
41
- type="filepath",
42
- height=512,
43
- width=512
44
  )
45
  src_prompt = gr.Text(
46
- label='Source Prompt',
47
  max_lines=1,
48
- placeholder='Source Prompt',
49
  )
50
  tgt_prompt = gr.Text(
51
- label='Target Prompt',
52
  max_lines=1,
53
- placeholder='Target Prompt',
54
  )
55
  with gr.Accordion("Advanced Options", open=False):
56
  seed = gr.Slider(
57
- label='seed',
58
- minimum=0,
59
- maximum=16*1024,
60
- value=7865,
61
- step=1
62
  )
63
  w1 = gr.Slider(
64
- label='w',
65
- minimum=1.0,
66
- maximum=3.0,
67
- value=1.5,
68
- step=0.05
69
  )
70
  # w2 = gr.Slider(
71
  # label='w2',
@@ -75,50 +66,44 @@ with gr.Blocks(css='app/style.css') as demo:
75
  # step=0.05
76
  # )
77
 
78
- run_button = gr.Button('Edit')
79
  with gr.Column():
80
  # result = gr.Gallery(label='Result')
81
- result = gr.Image(
82
- label="Result",
83
- type="pil",
84
- height=512,
85
- width=512
86
- )
87
-
88
- examples = [
89
- [
90
- "demo_im/WhatsApp Image 2024-05-17 at 17.32.53.jpeg", #input_image
91
- "a painting of a white cat sleeping on a lotus flower", #src_prompt
92
- "a painting of a white cat sleeping on a lotus flower", #tgt_prompt
93
- 4759, #seed
94
- 1.0, #w1
95
- # 1.1, #w2
96
- ],
97
- [
98
- "demo_im/pexels-pixabay-458976.less.png", #input_image
99
- "a squirrel standing in the grass", #src_prompt
100
- "a squirrel standing in the grass", #tgt_prompt
101
- 6128, #seed
102
- 1.25, #w1
103
- # 1.1, #w2
104
- ],
105
- ]
106
-
107
- gr.Examples(examples=examples,
108
- inputs=[
109
- input_image,
110
- src_prompt,
111
- tgt_prompt,
112
- seed,
113
- w1,
114
- # w2,
115
- ],
116
- outputs=[
117
- result
118
- ],
119
- fn=main_pipeline,
120
- cache_examples=True)
121
-
122
 
123
  inputs = [
124
  input_image,
@@ -128,9 +113,7 @@ with gr.Blocks(css='app/style.css') as demo:
128
  w1,
129
  # w2,
130
  ]
131
- outputs = [
132
- result
133
- ]
134
  run_button.click(fn=main_pipeline, inputs=inputs, outputs=outputs)
135
 
136
- demo.queue(max_size=50).launch(share=True, max_threads=100)
 
8
  from my_run import run as run_model
9
 
10
 
11
+ DESCRIPTION = """# Turbo Edit
12
+ """
13
+
14
 
15
  @spaces.GPU
16
  def main_pipeline(
17
+ input_image: str,
18
+ src_prompt: str,
19
+ tgt_prompt: str,
20
+ seed: int,
21
+ w1: float,
22
+ # w2: float,
23
+ ):
24
 
25
+ w2 = 1.0
26
+ res_image = run_model(input_image, src_prompt, tgt_prompt, seed, w1, w2)
27
 
28
+ return res_image
29
 
30
 
31
+ with gr.Blocks(css="app/style.css") as demo:
32
  gr.Markdown(DESCRIPTION)
33
 
34
  gr.HTML(
35
+ """<a href="https://huggingface.co/spaces/turboedit/turbo_edit?duplicate=true">
36
+ <img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>Duplicate the Space to run privately without waiting in queue"""
37
+ )
38
 
39
  with gr.Row():
40
  with gr.Column():
41
  input_image = gr.Image(
42
+ label="Input image", type="filepath", height=512, width=512
 
 
 
43
  )
44
  src_prompt = gr.Text(
45
+ label="Source Prompt",
46
  max_lines=1,
47
+ placeholder="Source Prompt",
48
  )
49
  tgt_prompt = gr.Text(
50
+ label="Target Prompt",
51
  max_lines=1,
52
+ placeholder="Target Prompt",
53
  )
54
  with gr.Accordion("Advanced Options", open=False):
55
  seed = gr.Slider(
56
+ label="seed", minimum=0, maximum=16 * 1024, value=7865, step=1
 
 
 
 
57
  )
58
  w1 = gr.Slider(
59
+ label="w", minimum=1.0, maximum=3.0, value=1.5, step=0.05
 
 
 
 
60
  )
61
  # w2 = gr.Slider(
62
  # label='w2',
 
66
  # step=0.05
67
  # )
68
 
69
+ run_button = gr.Button("Edit")
70
  with gr.Column():
71
  # result = gr.Gallery(label='Result')
72
+ result = gr.Image(label="Result", type="pil", height=512, width=512)
73
+
74
+ # examples = [
75
+ # [
76
+ # "demo_im/WhatsApp Image 2024-05-17 at 17.32.53.jpeg", #input_image
77
+ # "a painting of a white cat sleeping on a lotus flower", #src_prompt
78
+ # "a painting of a white cat sleeping on a lotus flower", #tgt_prompt
79
+ # 4759, #seed
80
+ # 1.0, #w1
81
+ # # 1.1, #w2
82
+ # ],
83
+ # [
84
+ # "demo_im/pexels-pixabay-458976.less.png", #input_image
85
+ # "a squirrel standing in the grass", #src_prompt
86
+ # "a squirrel standing in the grass", #tgt_prompt
87
+ # 6128, #seed
88
+ # 1.25, #w1
89
+ # # 1.1, #w2
90
+ # ],
91
+ # ]
92
+
93
+ # gr.Examples(examples=examples,
94
+ # inputs=[
95
+ # input_image,
96
+ # src_prompt,
97
+ # tgt_prompt,
98
+ # seed,
99
+ # w1,
100
+ # # w2,
101
+ # ],
102
+ # outputs=[
103
+ # result
104
+ # ],
105
+ # fn=main_pipeline,
106
+ # cache_examples=True)
 
 
 
 
 
 
107
 
108
  inputs = [
109
  input_image,
 
113
  w1,
114
  # w2,
115
  ]
116
+ outputs = [result]
 
 
117
  run_button.click(fn=main_pipeline, inputs=inputs, outputs=outputs)
118
 
119
+ demo.queue(max_size=50).launch(share=True, max_threads=100)