xingpng commited on
Commit
49c883f
1 Parent(s): 9f7f81b
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -65,7 +65,7 @@ pipe.enable_vae_tiling()
65
 
66
 
67
  blip_processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-large")
68
- blip_model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-large")
69
 
70
  target_content_blocks = BLOCKS['content']
71
  target_style_blocks = BLOCKS['style']
@@ -184,8 +184,8 @@ def create_image(content_image_pil,
184
  content_image_pil = Image.fromarray(
185
  np.zeros((1024, 1024, 3), dtype=np.uint8)).convert('RGB')
186
 
187
- if prompt is '':
188
- blip_model = blip_model.to(device)
189
  inputs = blip_processor(content_image_pil, return_tensors="pt").to(device)
190
  out = blip_model.generate(**inputs)
191
  prompt = blip_processor.decode(out[0], skip_special_tokens=True)
@@ -324,6 +324,7 @@ with block:
324
 
325
  prompt = gr.Textbox(label="Prompt",
326
  value="there is a small house with a sheep statue on top of it")
 
327
  if prompt_type == "caption of Blip" and target == "Image-Driven Style Transfer":
328
  prompt =''
329
 
 
65
 
66
 
67
  blip_processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-large")
68
+ blip_model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-large").to(device)
69
 
70
  target_content_blocks = BLOCKS['content']
71
  target_style_blocks = BLOCKS['style']
 
184
  content_image_pil = Image.fromarray(
185
  np.zeros((1024, 1024, 3), dtype=np.uint8)).convert('RGB')
186
 
187
+ if prompt == '':
188
+
189
  inputs = blip_processor(content_image_pil, return_tensors="pt").to(device)
190
  out = blip_model.generate(**inputs)
191
  prompt = blip_processor.decode(out[0], skip_special_tokens=True)
 
324
 
325
  prompt = gr.Textbox(label="Prompt",
326
  value="there is a small house with a sheep statue on top of it")
327
+
328
  if prompt_type == "caption of Blip" and target == "Image-Driven Style Transfer":
329
  prompt =''
330