KingNish commited on
Commit
e8a7086
Β·
verified Β·
1 Parent(s): 8257673

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -71,11 +71,13 @@ def king(type ,
71
  progress=gr.Progress(track_tqdm=True),
72
  ):
73
  if type=="Image Editing" :
74
- raw_image = Image.open(input_image)
75
  inputs = processor(raw_image, return_tensors="pt").to("cuda", torch.float16)
76
- out = model.generate(**inputs, min_length=10, max_length=25)
 
77
  caption = processor.decode(out[0], skip_special_tokens=True)
78
  instructions = f"{instruction} {caption} {instruction}"
 
79
  if randomize_seed:
80
  seed = random.randint(0, 99999)
81
  text_cfg_scale = text_cfg_scale
@@ -193,7 +195,7 @@ with gr.Blocks(css=css) as demo:
193
  generate_button = gr.Button("Generate")
194
 
195
  with gr.Row():
196
- input_image = gr.Image(label="Image", type="pil", interactive=True)
197
 
198
  with gr.Row():
199
  text_cfg_scale = gr.Number(value=7.3, step=0.1, label="Text CFG", interactive=True)
 
71
  progress=gr.Progress(track_tqdm=True),
72
  ):
73
  if type=="Image Editing" :
74
+ raw_image = Image.open(input_image).convert('RGB')
75
  inputs = processor(raw_image, return_tensors="pt").to("cuda", torch.float16)
76
+ pixel_values = inputs.pixel_values
77
+ out = model.generate(pixel_values=pixel_values, max_length=25, num_beams=3, repetition_penalty=2.5)
78
  caption = processor.decode(out[0], skip_special_tokens=True)
79
  instructions = f"{instruction} {caption} {instruction}"
80
+ print(instructions)
81
  if randomize_seed:
82
  seed = random.randint(0, 99999)
83
  text_cfg_scale = text_cfg_scale
 
195
  generate_button = gr.Button("Generate")
196
 
197
  with gr.Row():
198
+ input_image = gr.Image(label="Image", type='filepath', interactive=True)
199
 
200
  with gr.Row():
201
  text_cfg_scale = gr.Number(value=7.3, step=0.1, label="Text CFG", interactive=True)