lora微调qwen2-vl

This commit is contained in:
pmn 2025-06-26 14:56:56 +08:00
commit f38b91ce13
10 changed files with 4558 additions and 0 deletions

9
README.md Normal file
View File

@ -0,0 +1,9 @@
https://zhuanlan.zhihu.com/p/7144893529
用于测试Qwen-VL部署、微调
data2csv.py下载数据,生成csv
coco-2024-dataset.csv
csv2json.pycsv转换成json
data_vl.json
train.ipynb
训练全部代码

102
coco-2024-dataset.csv Normal file
View File

@ -0,0 +1,102 @@
image_path,caption
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000057870.jpg,A restaurant has modern wooden tables and chairs.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000384029.jpg,A man preparing desserts in a kitchen covered in frosting.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000222016.jpg,a big red telephone booth that a man is standing in
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000520950.jpg,the kitchen is full of spices on the rack
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000069675.jpg,A child and woman are cooking in the kitchen.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000547471.jpg,A black and white image of a man in a suit wearing glasses walking through a door.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000122688.jpg,The huge clock on the wall is near a wooden table.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000392136.jpg,A large bus and some people on the street.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000398494.jpg,A bicycle parked in a kitchen with a stove and cabinets.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000090570.jpg,"Two people in a food truck, one looking at an order."
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000504616.jpg,a person in white is standing in a kitchen
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000161919.jpg,A person is cutting a roast with a fork and knife.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000457732.jpg,a kitchen with a table and some chairs
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000044404.jpg,"A kitchen has wood cabinets, a dishwasher, sink, and refrigerator. "
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000004428.jpg,A chef preparing food inside of a kitchen near a window.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000170558.jpg,Adults using laptop computers while sitting at outdoor venue.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000405613.jpg,A group of men at a table preparing food together
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000283524.jpg,a man cutting up vegetables on top of a food cart.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000037015.jpg,Chefs are preparing food at a restaurant as patrons exit.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000071631.jpg,"Dining room table set for a casual meal, with flowers."
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000491269.jpg,A very cluttered but very clean kept kitchen.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000365363.jpg,Two people flying a kite above pine trees.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000064460.jpg,A kitchen in a restaurant with food on the counter.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000581674.jpg,Several kitchen workers making dishes in commercial kitchen.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000470072.jpg,a grill that has a bunch of burgers on it
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000344806.jpg,A man laying on his stomach with a towel on his head.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000084427.jpg,A small cluttered kitchen with a window and sink.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000317237.jpg,A small child eating noodles from a bowl in a kitchen
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000409382.jpg,People on a skateboard ramp with one doing a trick and one with skateboard on his head.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000570608.jpg,a kitchen that has a microwave and some cabinets in it
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000469605.jpg,there is a man standing on a field talking on the phone
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000356702.jpg,A couple of young men sitting in front of a child's laptop.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000405207.jpg,A large bottle of wine sitting on a kitchen counter.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000472925.jpg,A stove top with pots and pans in a kitchen.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000214704.jpg,A young man that is sitting at a kitchen table is looking of to the side.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000279108.jpg,A woman feeding a man food from a spoon.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000438422.jpg,A woman giving a taste test to a man.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000257350.jpg,a group of people riding bikes stopped in front of a building
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000393493.jpg,Little girl looking down at leaves with her bicycle with training wheels parked next to her.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000062426.jpg,A sink and bath in a small room.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000019380.jpg,A bathroom with a yellow sink next to a white bath tub.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000485894.jpg,A bathroom with a white bath tub sitting in a corner of a green room.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000446014.jpg,A girl washing her hands while looking into a mirror crying.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000530683.jpg,A woman in a dress riding a bicycle.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000292835.jpg,A view of a very dirty bathroom that needs to be cleaned.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000262845.jpg,A picture of a broken down bathroom with two sinks.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000299411.jpg,a bathroom that has a sink and a toilet in it
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000042493.jpg,Two mountain bikers take a break on a path.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000239811.jpg,A solid white bicycle is parked next to statues on a sidewalk.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000002024.jpg,A bathroom looks new with nothing in it.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000095133.jpg,a bathroom scene with a wooden door and a sink in view
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000287541.jpg,"Two bathroom sinks mounted against a mirror, with soap in between the two sinks."
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000441488.jpg,MAN KNEELING BETWEEN TWO BICYCLES LOOKING AT HIS PHONE
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000179620.jpg,"A toilet bowl with rolls of toilet paper stacked next to it
"
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000070000.jpg,Bright loft space with large rustic dining table and bikes on the wall.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000536587.jpg,Adjustable magnifying mirror attached to a bathroom wall
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000543877.jpg,"A bathroom features white, bowl sinks and a bathtub."
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000420721.jpg,A large furry cat pulling up the bathroom carpet
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000540162.jpg,Toilet with upraised lid sitting next to bookshelves.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000218956.jpg,A man standing in front of a white toilet in a restroom.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000318574.jpg,Bicycle wheels are lined up on bicycles in a row.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000172899.jpg,"A bathroom scene complete with a tab, sink and toilet."
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000352884.jpg,"Bathroom with destroyed walls, a sink and a mirrored cabinet. "
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000394326.jpg,A black and white photo of restroom toilet with a filthy floor.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000535786.jpg,A toilet with a bow on it inside a bathroom.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000357684.jpg,Several groups of people are standing outside of a building.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000576757.jpg,An unfinished bathroom has a toilet and tools
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000165499.jpg,A bathroom shower with glass doors and tile walls.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000181104.jpg,A white bathtub sitting in a bathroom next to a sink.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000055627.jpg,A bathroom is freshly cleaned and ready for hotel patrons.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000241364.jpg,A mirror that is sitting behind a sink.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000209967.jpg,A sink and vanity with overhead lights a decorative piece on the wall and a commode.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000153674.jpg,A bathroom sink with the faucet on the side
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000354444.jpg,a lady sitting in a van with several seagulls landing on the top
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000098760.jpg,A dog sticks its out out the window of a car.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000311914.jpg,A school bus parked with it's stop sign closed.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000467311.jpg,A bus and a few other vehicles that appear to be traveling down the road.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000236772.jpg,In the bathroom a toilet is full of ice cubes.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000049183.jpg,A white toilet commode sits on a tile floor.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000426038.jpg,A boat with lots of seats and large windows.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000309322.jpg,The Phillips 66 clocks is in front of some posters.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000318189.jpg,An old red and yellow car with a yellow surfboard on top.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000343322.jpg,Blue and white antique car at intersection of city roadway.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000036633.jpg,A toilet with a trash can and a roll of toilet paper on top
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000213546.jpg,"A mirrored bathroom features duel, white porcelain sinks and silver faucets. "
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000378710.jpg,A wall with four mounted urinals on it.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000189993.jpg,A black bear on display in a library.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000551125.jpg,A group of three urinals mounted to a wall.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000077806.jpg,Small dog in wire basket transported on motor scooter in city.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000546451.jpg,A small restroom that is painted the color blue.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000444546.jpg,a spoon and a fork that is on a table
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000147016.jpg,"A toilet connected to a wire, next to a speaker."
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000497616.jpg,A black and white photo of a cat sitting on a chair.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000520208.jpg,a spoon sitting on some food in a bowl
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000199628.jpg,A public restroom has two sinks shaped like fancy vases.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000280980.jpg,A man in a costume and wig is using a urinal.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000167613.jpg,A bathroom with a white toilet and sink and checkered tile.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000142088.jpg,Black motorcycle sitting underneath an overhang outdoors.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000301778.jpg,Dirty bathroom floor with a toilet and a toilet brush next to it.
/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000454325.jpg,A modern restroom is equipped with fashionable sinks and urinals surrounded by architectural subway tile.
1 image_path caption
2 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000057870.jpg A restaurant has modern wooden tables and chairs.
3 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000384029.jpg A man preparing desserts in a kitchen covered in frosting.
4 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000222016.jpg a big red telephone booth that a man is standing in
5 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000520950.jpg the kitchen is full of spices on the rack
6 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000069675.jpg A child and woman are cooking in the kitchen.
7 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000547471.jpg A black and white image of a man in a suit wearing glasses walking through a door.
8 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000122688.jpg The huge clock on the wall is near a wooden table.
9 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000392136.jpg A large bus and some people on the street.
10 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000398494.jpg A bicycle parked in a kitchen with a stove and cabinets.
11 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000090570.jpg Two people in a food truck, one looking at an order.
12 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000504616.jpg a person in white is standing in a kitchen
13 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000161919.jpg A person is cutting a roast with a fork and knife.
14 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000457732.jpg a kitchen with a table and some chairs
15 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000044404.jpg A kitchen has wood cabinets, a dishwasher, sink, and refrigerator.
16 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000004428.jpg A chef preparing food inside of a kitchen near a window.
17 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000170558.jpg Adults using laptop computers while sitting at outdoor venue.
18 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000405613.jpg A group of men at a table preparing food together
19 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000283524.jpg a man cutting up vegetables on top of a food cart.
20 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000037015.jpg Chefs are preparing food at a restaurant as patrons exit.
21 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000071631.jpg Dining room table set for a casual meal, with flowers.
22 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000491269.jpg A very cluttered but very clean kept kitchen.
23 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000365363.jpg Two people flying a kite above pine trees.
24 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000064460.jpg A kitchen in a restaurant with food on the counter.
25 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000581674.jpg Several kitchen workers making dishes in commercial kitchen.
26 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000470072.jpg a grill that has a bunch of burgers on it
27 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000344806.jpg A man laying on his stomach with a towel on his head.
28 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000084427.jpg A small cluttered kitchen with a window and sink.
29 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000317237.jpg A small child eating noodles from a bowl in a kitchen
30 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000409382.jpg People on a skateboard ramp with one doing a trick and one with skateboard on his head.
31 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000570608.jpg a kitchen that has a microwave and some cabinets in it
32 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000469605.jpg there is a man standing on a field talking on the phone
33 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000356702.jpg A couple of young men sitting in front of a child's laptop.
34 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000405207.jpg A large bottle of wine sitting on a kitchen counter.
35 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000472925.jpg A stove top with pots and pans in a kitchen.
36 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000214704.jpg A young man that is sitting at a kitchen table is looking of to the side.
37 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000279108.jpg A woman feeding a man food from a spoon.
38 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000438422.jpg A woman giving a taste test to a man.
39 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000257350.jpg a group of people riding bikes stopped in front of a building
40 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000393493.jpg Little girl looking down at leaves with her bicycle with training wheels parked next to her.
41 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000062426.jpg A sink and bath in a small room.
42 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000019380.jpg A bathroom with a yellow sink next to a white bath tub.
43 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000485894.jpg A bathroom with a white bath tub sitting in a corner of a green room.
44 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000446014.jpg A girl washing her hands while looking into a mirror crying.
45 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000530683.jpg A woman in a dress riding a bicycle.
46 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000292835.jpg A view of a very dirty bathroom that needs to be cleaned.
47 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000262845.jpg A picture of a broken down bathroom with two sinks.
48 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000299411.jpg a bathroom that has a sink and a toilet in it
49 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000042493.jpg Two mountain bikers take a break on a path.
50 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000239811.jpg A solid white bicycle is parked next to statues on a sidewalk.
51 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000002024.jpg A bathroom looks new with nothing in it.
52 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000095133.jpg a bathroom scene with a wooden door and a sink in view
53 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000287541.jpg Two bathroom sinks mounted against a mirror, with soap in between the two sinks.
54 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000441488.jpg MAN KNEELING BETWEEN TWO BICYCLES LOOKING AT HIS PHONE
55 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000179620.jpg A toilet bowl with rolls of toilet paper stacked next to it
56 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000070000.jpg Bright loft space with large rustic dining table and bikes on the wall.
57 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000536587.jpg Adjustable magnifying mirror attached to a bathroom wall
58 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000543877.jpg A bathroom features white, bowl sinks and a bathtub.
59 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000420721.jpg A large furry cat pulling up the bathroom carpet
60 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000540162.jpg Toilet with upraised lid sitting next to bookshelves.
61 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000218956.jpg A man standing in front of a white toilet in a restroom.
62 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000318574.jpg Bicycle wheels are lined up on bicycles in a row.
63 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000172899.jpg A bathroom scene complete with a tab, sink and toilet.
64 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000352884.jpg Bathroom with destroyed walls, a sink and a mirrored cabinet.
65 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000394326.jpg A black and white photo of restroom toilet with a filthy floor.
66 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000535786.jpg A toilet with a bow on it inside a bathroom.
67 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000357684.jpg Several groups of people are standing outside of a building.
68 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000576757.jpg An unfinished bathroom has a toilet and tools
69 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000165499.jpg A bathroom shower with glass doors and tile walls.
70 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000181104.jpg A white bathtub sitting in a bathroom next to a sink.
71 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000055627.jpg A bathroom is freshly cleaned and ready for hotel patrons.
72 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000241364.jpg A mirror that is sitting behind a sink.
73 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000209967.jpg A sink and vanity with overhead lights a decorative piece on the wall and a commode.
74 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000153674.jpg A bathroom sink with the faucet on the side
75 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000354444.jpg a lady sitting in a van with several seagulls landing on the top
76 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000098760.jpg A dog sticks its out out the window of a car.
77 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000311914.jpg A school bus parked with it's stop sign closed.
78 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000467311.jpg A bus and a few other vehicles that appear to be traveling down the road.
79 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000236772.jpg In the bathroom a toilet is full of ice cubes.
80 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000049183.jpg A white toilet commode sits on a tile floor.
81 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000426038.jpg A boat with lots of seats and large windows.
82 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000309322.jpg The Phillips 66 clocks is in front of some posters.
83 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000318189.jpg An old red and yellow car with a yellow surfboard on top.
84 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000343322.jpg Blue and white antique car at intersection of city roadway.
85 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000036633.jpg A toilet with a trash can and a roll of toilet paper on top
86 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000213546.jpg A mirrored bathroom features duel, white porcelain sinks and silver faucets.
87 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000378710.jpg A wall with four mounted urinals on it.
88 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000189993.jpg A black bear on display in a library.
89 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000551125.jpg A group of three urinals mounted to a wall.
90 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000077806.jpg Small dog in wire basket transported on motor scooter in city.
91 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000546451.jpg A small restroom that is painted the color blue.
92 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000444546.jpg a spoon and a fork that is on a table
93 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000147016.jpg A toilet connected to a wire, next to a speaker.
94 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000497616.jpg A black and white photo of a cat sitting on a chair.
95 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000520208.jpg a spoon sitting on some food in a bowl
96 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000199628.jpg A public restroom has two sinks shaped like fancy vases.
97 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000280980.jpg A man in a costume and wig is using a urinal.
98 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000167613.jpg A bathroom with a white toilet and sink and checkered tile.
99 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000142088.jpg Black motorcycle sitting underneath an overhang outdoors.
100 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000301778.jpg Dirty bathroom floor with a toilet and a toilet brush next to it.
101 /root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000454325.jpg A modern restroom is equipped with fashionable sinks and urinals surrounded by architectural subway tile.

27
csv2json.py Normal file
View File

@ -0,0 +1,27 @@
import pandas as pd
import json
# 载入CSV文件
df = pd.read_csv('qwen-test/coco-2024-dataset.csv')
conversations = []
# 添加对话数据
for i in range(len(df)):
conversations.append({
"id": f"identity_{i+1}",
"conversations": [
{
"from": "user",
"value": f"COCO Yes: <|vision_start|>{df.iloc[i]['image_path']}<|vision_end|>"
},
{
"from": "assistant",
"value": df.iloc[i]['caption']
}
]
})
# 保存为Json
with open('/root/PMN_WS/qwen-test/data_vl.json', 'w', encoding='utf-8') as f:
json.dump(conversations, f, ensure_ascii=False, indent=2)

146
data2csv.py Normal file
View File

@ -0,0 +1,146 @@
import os
import pandas as pd
import json
import requests
# #查看json文件
# print_json_tree(data)
class image_caption_json():
"""
{
"info": {...},
"licenses": [...],
"images": [...],
"annotations": [...]
}
"""
def __init__(self,json_path,data_number):
self.json_path = json_path
self.data_number = data_number
with open(self.json_path, 'r') as f:
self.data = json.load(f)
# 树状输出json
def print_json_tree(self, indent=1):
for key, value in self.data.items():
print(' ' * indent + str(key), end='\n')
# 如果值是列表,统计列表长度
if isinstance(value, list):
value_count = len(value)
# 如果值是字典,统计字典的键数量
elif isinstance(value, dict):
value_count = len(value.keys())
# 如果值是单个值数量为1
else:
value_count = 1
print(value_count)
# if isinstance(value, dict):
# print()
# print_json_tree(value, indent + 1)
# else:
# print(': ' + str(value))
def download_image(self,url, save_dir, filename, timeout=10):
# 1.创建保存路径
if not os.path.exists(save_dir):
os.makedirs(save_dir, exist_ok=True)
try:
response = requests.get(url, stream=True)
response.raise_for_status() # 检查请求是否成功
img_path = f"{save_dir}/{filename}"
with open(img_path, "wb") as f:
for chunk in response.iter_content(1024):
f.write(chunk)
print(f"✅ Successfully saved {filename} to: {img_path} from: {url}\n")
return img_path
except Exception as e:
print(f"❌ Failed to download from[{url}]: {e}\n")
return None
def image_annotation(self,save_dir,csv_path):
# if os.path.exists(save_dir):
# print('coco_2014_caption目录已存在,跳过数据处理步骤')
# return 0
# 全局变量记录最近成功的来源0-"coco" 或 1-"flickr"
LAST_SUCCESSFUL_SOURCE = 0
# 初始化存储图片路径和描述的列表
image_paths = []
captions = []
# 获取前data_number个annotation
for i, img_info in enumerate(self.data['images'][:self.data_number]):
# 获取对应的caption和image
img_id = img_info['id']
filename = img_info['file_name']
coco_url = img_info['coco_url']
flickr_url = img_info['flickr_url']
# 查找image对应的caption
# # 匹配所有
# match_annotation =[annotation['caption'] for annotation in self.data['annotations'] if annotation['image_id'] == img_id]
# 只匹配第一个
caption =next((annotation['caption'] for annotation in self.data['annotations'] if annotation['image_id'] == img_id),None)
print(f"{i+1}. 图片ID: {img_id}")
print(f" 文件名: {filename}")
print(f" Caption: {caption}")
# print(f" coco_url: {coco_url}")
# 根据 url 下载图片
if LAST_SUCCESSFUL_SOURCE:
first_url = flickr_url
second_url = coco_url
else:
first_url = coco_url
second_url = flickr_url
image_path = self.download_image(first_url,save_dir,filename)
if not image_path:
image_path = self.download_image(second_url,save_dir,filename)
if image_path:
LAST_SUCCESSFUL_SOURCE =1-LAST_SUCCESSFUL_SOURCE
else:
print(f"❌❌ Failed to download ]\n")
continue
# 将路径和描述添加到列表中
image_paths.append(image_path)
captions.append(caption)
# 将图片路径和描述保存为CSV文件
df = pd.DataFrame({
'image_path': image_paths,
'caption': captions
})
# 将数据保存为CSV文件
df.to_csv(csv_path, index=False)
print(f'数据处理完成')
if __name__ == '__main__':
file_path = '/root/PMN_WS/coco_2014_caption/annotations/captions_train2014.json'
MAX_DATA_NUMBER = 100
image_caption = image_caption_json(file_path,MAX_DATA_NUMBER)
save_dir='/root/PMN_WS/qwen-test/coco_2014_image'
csv_path = '/root/PMN_WS/qwen-test/coco-2024-dataset.csv'
image_caption.image_annotation(save_dir,csv_path)
# image_caption.print_json_tree()

1302
data_vl.json Normal file

File diff suppressed because it is too large Load Diff

54
data_vl_test.json Normal file
View File

@ -0,0 +1,54 @@
[
{
"id": "identity_97",
"conversations": [
{
"from": "user",
"value": "COCO Yes: <|vision_start|>/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000167613.jpg<|vision_end|>"
},
{
"from": "assistant",
"value": "A bathroom with a white toilet and sink and checkered tile."
}
]
},
{
"id": "identity_98",
"conversations": [
{
"from": "user",
"value": "COCO Yes: <|vision_start|>/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000142088.jpg<|vision_end|>"
},
{
"from": "assistant",
"value": "Black motorcycle sitting underneath an overhang outdoors. "
}
]
},
{
"id": "identity_99",
"conversations": [
{
"from": "user",
"value": "COCO Yes: <|vision_start|>/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000301778.jpg<|vision_end|>"
},
{
"from": "assistant",
"value": "Dirty bathroom floor with a toilet and a toilet brush next to it."
}
]
},
{
"id": "identity_100",
"conversations": [
{
"from": "user",
"value": "COCO Yes: <|vision_start|>/root/PMN_WS/qwen-test/coco_2014_image/COCO_train2014_000000454325.jpg<|vision_end|>"
},
{
"from": "assistant",
"value": "A modern restroom is equipped with fashionable sinks and urinals surrounded by architectural subway tile."
}
]
}
]

1250
data_vl_train.json Normal file

File diff suppressed because it is too large Load Diff

69
model_download.py Normal file
View File

@ -0,0 +1,69 @@
import torch
from datasets import Dataset
from modelscope import snapshot_download, AutoTokenizer
from qwen_vl_utils import process_vision_info
from transformers import (
TrainingArguments,
Trainer,
DataCollatorForSeq2Seq,
Qwen2VLForConditionalGeneration,
AutoProcessor,
)
import json
# 在modelscope上下载Qwen2-VL模型到本地目录下
# model_dir = snapshot_download(
# model_id="Qwen/Qwen2-VL-2B-Instruct",
# cache_dir=model_path,
# revision="master"
# )
# print(f"模型已下载到: {model_dir}")
model_dir = "/root/PMN_WS/qwen-test/model/Qwen/Qwen2-VL-2B-Instruct"
# 使用Transformers加载模型权重
tokenizer = AutoTokenizer.from_pretrained(model_dir, use_fast=False, trust_remote_code=True)
processor = AutoProcessor.from_pretrained(model_dir)
model = Qwen2VLForConditionalGeneration.from_pretrained(
model_dir, torch_dtype="auto", device_map="auto"
)
messages = [
{
"role": "user",
"content": [
{
"type": "image",
"image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
},
{"type": "text", "text": "Describe this image."},
],
}
]
# Preparation for inference
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
# Inference: Generation of the output
generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)

1599
train.ipynb Normal file

File diff suppressed because it is too large Load Diff

0
train.json Normal file
View File