wiusdy commited on
Commit
ad1c334
1 Parent(s): 79c1479

solving problemas

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. inference.py +8 -11
app.py CHANGED
@@ -7,7 +7,7 @@ inference = Inference()
7
 
8
 
9
  with gr.Blocks() as block:
10
- options = gr.Dropdown(choices=["Blip Saffal", "Blip Control Net"], label="Models", info="Select the model to use..", )
11
  # need to improve this one...
12
 
13
  txt = gr.Textbox(label="Insert a question..", lines=2)
 
7
 
8
 
9
  with gr.Blocks() as block:
10
+ options = gr.Dropdown(choices=["Blip Saffal", "Blip CN"], label="Models", info="Select the model to use..", )
11
  # need to improve this one...
12
 
13
  txt = gr.Textbox(label="Insert a question..", lines=2)
inference.py CHANGED
@@ -6,20 +6,17 @@ class Inference:
6
  self.blip_processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-base")
7
  self.blip_model_saffal = BlipForQuestionAnswering.from_pretrained("wiusdy/blip_pretrained_saffal_fashion_finetuning")
8
  self.blip_model_control_net = BlipForQuestionAnswering.from_pretrained("wiusdy/blip_pretrained_control_net_fashion_finetuning")
9
-
10
  logging.set_verbosity_info()
11
  self.logger = logging.get_logger("transformers")
12
 
13
- def inference(self, options, image, text):
14
- if options == "Blip Saffal":
15
- self.logger.info(f"Running inference for model BLIP Saffal")
16
- BLIP_saffal_inference = self.__inference_saffal_blip(image, text)
17
- return BLIP_saffal_inference
18
-
19
- elif options == "Blip Control Net":
20
- self.logger.info(f"Running inference for model BLIP Control Net")
21
- BLIP_control_net_inference = self.__inference_control_net_blip(image, text)
22
- return BLIP_control_net_inference
23
 
24
  def __inference_saffal_blip(self, image, text):
25
  encoding = self.blip_processor(image, text, return_tensors="pt")
 
6
  self.blip_processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-base")
7
  self.blip_model_saffal = BlipForQuestionAnswering.from_pretrained("wiusdy/blip_pretrained_saffal_fashion_finetuning")
8
  self.blip_model_control_net = BlipForQuestionAnswering.from_pretrained("wiusdy/blip_pretrained_control_net_fashion_finetuning")
 
9
  logging.set_verbosity_info()
10
  self.logger = logging.get_logger("transformers")
11
 
12
+ def inference(self, selected, image, text):
13
+ self.logger.info(f"selected model {selected}")
14
+ if selected == "Blip Saffal":
15
+ return self.__inference_saffal_blip(image, text)
16
+ elif selected == "Blip CN":
17
+ return self.__inference_control_net_blip(image, text)
18
+ else:
19
+ self.logger.warning("Please select a model to make the inference..")
 
 
20
 
21
  def __inference_saffal_blip(self, image, text):
22
  encoding = self.blip_processor(image, text, return_tensors="pt")