aifeifei798 commited on
Commit
29c38ce
·
verified ·
1 Parent(s): b88ce12

Upload 4 files

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. feifeilib/feifeiflorencebase.py +5 -0
app.py CHANGED
@@ -19,7 +19,7 @@ with gr.Blocks() as demo:
19
  gr.Markdown(DESCRIPTION)
20
  with gr.Tab(label="Florence-2 Image to Flux Prompt"):
21
  with gr.Row():
22
- input_img = gr.Image(label="Input Picture",height=320)
23
  with gr.Row():
24
  submit_btn = gr.Button(value="GenPrompt")
25
  with gr.Row():
 
19
  gr.Markdown(DESCRIPTION)
20
  with gr.Tab(label="Florence-2 Image to Flux Prompt"):
21
  with gr.Row():
22
+ input_img = gr.Image(label="Input Picture",height=320,type="filepath")
23
  with gr.Row():
24
  submit_btn = gr.Button(value="GenPrompt")
25
  with gr.Row():
feifeilib/feifeiflorencebase.py CHANGED
@@ -114,6 +114,11 @@ def draw_ocr_bboxes(image, prediction):
114
  return image
115
 
116
  def process_image(image, task_prompt = "More Detailed Caption", text_input=None, model_id='microsoft/Florence-2-base'):
 
 
 
 
 
117
  image = Image.fromarray(image) # Convert NumPy array to PIL Image
118
  if task_prompt == 'Caption':
119
  task_prompt = '<CAPTION>'
 
114
  return image
115
 
116
  def process_image(image, task_prompt = "More Detailed Caption", text_input=None, model_id='microsoft/Florence-2-base'):
117
+ image = Image.open(image_path).convert("RGB")
118
+ base_height = 512
119
+ h_percent = (base_height / float(image.size[1]))
120
+ w_size = int((float(image.size[0]) * float(h_percent)))
121
+ image = image.resize((w_size, base_height), Image.LANCZOS)
122
  image = Image.fromarray(image) # Convert NumPy array to PIL Image
123
  if task_prompt == 'Caption':
124
  task_prompt = '<CAPTION>'