Daominhwysi
commited on
Commit
•
d555793
1
Parent(s):
9898bd6
Update README.md
Browse files
README.md
CHANGED
@@ -45,8 +45,77 @@ import pandas as pd
|
|
45 |
import logging
|
46 |
|
47 |
try:
|
48 |
-
with
|
|
|
|
|
|
|
|
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
df = pd.concat([df_1, df_2], ignore_index=True)
|
51 |
df.head()
|
52 |
```
|
|
|
45 |
import logging
|
46 |
|
47 |
try:
|
48 |
+
with open('/content/datasets/cinamonai/labels.json', 'r') as file:
|
49 |
+
labels = json.load(file)
|
50 |
+
df_1 = pd.DataFrame(list(labels.items()), columns=['file_name', 'label'])
|
51 |
+
except Exception as e:
|
52 |
+
logging.error(f"Lỗi khi tải nhãn: {e}")
|
53 |
|
54 |
+
df_1['file_name'] = df_1['file_name'].apply(lambda x: f'/content/datasets/cinamonai/data/{x}.jpeg')
|
55 |
+
|
56 |
+
df_1.head()
|
57 |
+
```
|
58 |
+
|
59 |
+
### Đọc Dữ Liệu từ `labels.json` (VNonDB)
|
60 |
+
|
61 |
+
```python
|
62 |
+
import json
|
63 |
+
import pandas as pd
|
64 |
+
import logging
|
65 |
+
|
66 |
+
try:
|
67 |
+
with open('/content/datasets/vnondb/labels.json', 'r') as file:
|
68 |
+
labels = json.load(file)
|
69 |
+
df_2 = pd.DataFrame(list(labels.items()), columns=['file_name', 'label'])
|
70 |
+
except Exception as e:
|
71 |
+
logging.error(f"Lỗi khi tải nhãn: {e}")
|
72 |
+
|
73 |
+
df_2['file_name'] = df_2['file_name'].apply(lambda x: f'/content/datasets/vnondb/outputs_image/{x}.jpeg')
|
74 |
+
|
75 |
+
df_2.head()
|
76 |
+
```
|
77 |
+
|
78 |
+
## Hiển Thị Ảnh và Nhãn
|
79 |
+
|
80 |
+
### Hiển Thị Ảnh từ `df_1`
|
81 |
+
|
82 |
+
```python
|
83 |
+
import pandas as pd
|
84 |
+
import random
|
85 |
+
from PIL import Image
|
86 |
+
import matplotlib.pyplot as plt
|
87 |
+
|
88 |
+
random_row = df_1.sample(n=1).iloc[0]
|
89 |
+
file_path = random_row['file_name']
|
90 |
+
image = Image.open(file_path).convert('RGB')
|
91 |
+
plt.figure(figsize=(20, 10))
|
92 |
+
plt.imshow(image)
|
93 |
+
plt.axis('off')
|
94 |
+
plt.show()
|
95 |
+
|
96 |
+
print(f"Labeled as: {random_row['label']}")
|
97 |
+
```
|
98 |
+
|
99 |
+
### Hiển Thị Ảnh từ `df_2`
|
100 |
+
|
101 |
+
```python
|
102 |
+
import pandas as pd
|
103 |
+
import random
|
104 |
+
from PIL import Image
|
105 |
+
import matplotlib.pyplot as plt
|
106 |
+
|
107 |
+
random_row = df_2.sample(n=1).iloc[0]
|
108 |
+
file_path = random_row['file_name']
|
109 |
+
image = Image.open(file_path).convert('RGB')
|
110 |
+
plt.figure(figsize=(20, 10))
|
111 |
+
plt.imshow(image)
|
112 |
+
plt.axis('off')
|
113 |
+
plt.show()
|
114 |
+
|
115 |
+
print(f"Labeled as: {random_row['label']}")
|
116 |
+
```
|
117 |
+
## Kết hợp 2 DatasetDataset
|
118 |
+
```
|
119 |
df = pd.concat([df_1, df_2], ignore_index=True)
|
120 |
df.head()
|
121 |
```
|