зеркало из
				https://github.com/ssciwr/AMMICO.git
				synced 2025-10-31 05:56:05 +02:00 
			
		
		
		
	fixing smell code smells
Этот коммит содержится в:
		
							родитель
							
								
									d1f65d016d
								
							
						
					
					
						Коммит
						ea297ea23d
					
				| @ -350,7 +350,7 @@ class MultimodalSearch(AnalysisMethod): | |||||||
| 
 | 
 | ||||||
|     def itm_text_precessing(self, search_query): |     def itm_text_precessing(self, search_query): | ||||||
|         for query in search_query: |         for query in search_query: | ||||||
|             if not (len(query) == 1) and (query in ("image", "text_input")): |             if (len(query) != 1) and (query in ("image", "text_input")): | ||||||
|                 raise SyntaxError( |                 raise SyntaxError( | ||||||
|                     'Each querry must contain either an "image" or a "text_input"' |                     'Each querry must contain either an "image" or a "text_input"' | ||||||
|                 ) |                 ) | ||||||
|  | |||||||
| @ -58,9 +58,9 @@ class SummaryDetector(AnalysisMethod): | |||||||
| 
 | 
 | ||||||
|     def analyse_questions(self, list_of_questions): |     def analyse_questions(self, list_of_questions): | ||||||
|         ( |         ( | ||||||
|             summary_VQA_model, |             summary_vqa_model, | ||||||
|             summary_VQA_vis_processors, |             summary_vqa_vis_processors, | ||||||
|             summary_VQA_txt_processors, |             summary_vqa_txt_processors, | ||||||
|         ) = load_model_and_preprocess( |         ) = load_model_and_preprocess( | ||||||
|             name="blip_vqa", |             name="blip_vqa", | ||||||
|             model_type="vqav2", |             model_type="vqav2", | ||||||
| @ -71,18 +71,18 @@ class SummaryDetector(AnalysisMethod): | |||||||
|             path = self.subdict["filename"] |             path = self.subdict["filename"] | ||||||
|             raw_image = Image.open(path).convert("RGB") |             raw_image = Image.open(path).convert("RGB") | ||||||
|             image = ( |             image = ( | ||||||
|                 summary_VQA_vis_processors["eval"](raw_image) |                 summary_vqa_vis_processors["eval"](raw_image) | ||||||
|                 .unsqueeze(0) |                 .unsqueeze(0) | ||||||
|                 .to(self.summary_device) |                 .to(self.summary_device) | ||||||
|             ) |             ) | ||||||
|             question_batch = [] |             question_batch = [] | ||||||
|             for quest in list_of_questions: |             for quest in list_of_questions: | ||||||
|                 question_batch.append(summary_VQA_txt_processors["eval"](quest)) |                 question_batch.append(summary_vqa_txt_processors["eval"](quest)) | ||||||
|             batch_size = len(list_of_questions) |             batch_size = len(list_of_questions) | ||||||
|             image_batch = image.repeat(batch_size, 1, 1, 1) |             image_batch = image.repeat(batch_size, 1, 1, 1) | ||||||
| 
 | 
 | ||||||
|             with no_grad(): |             with no_grad(): | ||||||
|                 answers_batch = summary_VQA_model.predict_answers( |                 answers_batch = summary_vqa_model.predict_answers( | ||||||
|                     samples={"image": image_batch, "text_input": question_batch}, |                     samples={"image": image_batch, "text_input": question_batch}, | ||||||
|                     inference_method="generate", |                     inference_method="generate", | ||||||
|                 ) |                 ) | ||||||
|  | |||||||
		Загрузка…
	
	
			
			x
			
			
		
	
		Ссылка в новой задаче
	
	Block a user
	 Petr Andriushchenko
						Petr Andriushchenko