Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature_img_folder_None #1736

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion llava/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,11 +663,13 @@ def __init__(self, data_path: str,
data_args: DataArguments):
super(LazySupervisedDataset, self).__init__()
list_data_dict = json.load(open(data_path, "r"))


rank0_print("Formatting inputs...Skip in lazy mode")
self.tokenizer = tokenizer
self.list_data_dict = list_data_dict
self.data_args = data_args


def __len__(self):
return len(self.list_data_dict)
Expand Down Expand Up @@ -698,7 +700,14 @@ def __getitem__(self, i) -> Dict[str, torch.Tensor]:
image_file = self.list_data_dict[i]['image']
image_folder = self.data_args.image_folder
processor = self.data_args.image_processor
image = Image.open(os.path.join(image_folder, image_file)).convert('RGB')

if not image_folder==None:
img_path = os.path.join(image_folder, image_file)
else:
img_path = image_file


image = Image.open(img_path).convert('RGB')
if self.data_args.image_aspect_ratio == 'pad':
def expand2square(pil_img, background_color):
width, height = pil_img.size
Expand Down Expand Up @@ -989,3 +998,11 @@ def make_inputs_require_grad(module, input, output):

if __name__ == "__main__":
train()





"""
rsync -avz --exclude='*.out' /home/khayatan/llava/LLaVA/llava/train/train.py [email protected]:/lustre/fswork/projects/rech/lqq/uja56bm/LLaVA/llava/train/
"""