Update README.md
Browse files
README.md
CHANGED
@@ -49,6 +49,8 @@ Image with caption:
|
|
49 |
-->
|
50 |
|
51 |
# Dataset Card for Fish-Visual Trait Analysis (Fish-Vista)
|
|
|
|
|
52 |
|![Figure 1](https://huggingface.co/datasets/imageomics/fish-vista/resolve/main/metadata/figures/FishVista.png)|
|
53 |
|:--|
|
54 |
|**Figure 1.** A schematic representation of the different tasks in Fish-Vista Dataset. |
|
@@ -73,6 +75,10 @@ mv AllImages Images
|
|
73 |
|
74 |
* You should now have all the images in the *Images* directory
|
75 |
|
|
|
|
|
|
|
|
|
76 |
* Run the following commands to download and process copyrighted images
|
77 |
```bash
|
78 |
python download_and_process_nd_images.py --save_dir Images
|
@@ -180,6 +186,47 @@ CSV Columns are as follows:
|
|
180 |
|
181 |
For each task (or subset), the split is indicated by the CSV name (e.g., `classification_<split>.csv`). More information is provided in [Data Instances](#data-instances), above.
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
## Dataset Details
|
185 |
|
|
|
49 |
-->
|
50 |
|
51 |
# Dataset Card for Fish-Visual Trait Analysis (Fish-Vista)
|
52 |
+
* Note that the '**</Use this dataset>**' option will only load the CSV files. To download the entire dataset, including all images and segmentation annotations, refer to [Instructions for downloading dataset and images](https://huggingface.co/datasets/imageomics/fish-vista#instructions-for-downloading-dataset-and-images).
|
53 |
+
* See [Example Code to Use the Segmentation Dataset])(https://huggingface.co/datasets/imageomics/fish-vista#example-code-to-use-the-segmentation-dataset)
|
54 |
|![Figure 1](https://huggingface.co/datasets/imageomics/fish-vista/resolve/main/metadata/figures/FishVista.png)|
|
55 |
|:--|
|
56 |
|**Figure 1.** A schematic representation of the different tasks in Fish-Vista Dataset. |
|
|
|
75 |
|
76 |
* You should now have all the images in the *Images* directory
|
77 |
|
78 |
+
* Install requirements.txt
|
79 |
+
```bash
|
80 |
+
pip install -r requirements.txt
|
81 |
+
```
|
82 |
* Run the following commands to download and process copyrighted images
|
83 |
```bash
|
84 |
python download_and_process_nd_images.py --save_dir Images
|
|
|
186 |
|
187 |
For each task (or subset), the split is indicated by the CSV name (e.g., `classification_<split>.csv`). More information is provided in [Data Instances](#data-instances), above.
|
188 |
|
189 |
+
## Example Code to Use the Segmentation Dataset
|
190 |
+
|
191 |
+
We provide an example code to use the FV-1200 segmentation dataset for convenience of users. Please install *pillow*, *numpy*, *pandas* and *matplotlib* before trying the code:
|
192 |
+
|
193 |
+
```python
|
194 |
+
from PIL import Image
|
195 |
+
import os
|
196 |
+
import numpy as np
|
197 |
+
import pandas as pd
|
198 |
+
import matplotlib.pyplot as plt
|
199 |
+
import json
|
200 |
+
|
201 |
+
# Set the the fish_vista_repo_dir to the path of your cloned fish-vista HF repository. This code assumes you are running from within the fish-vista directory
|
202 |
+
fish_vista_repo_dir = '.'
|
203 |
+
|
204 |
+
# segmentation_masks/images contains the annotated segmentation maps for the traits.
|
205 |
+
# If image filename is <image_filename>.jpg, the corresponding annotation is contained in segmentation_masks/images/<image_filename>.png
|
206 |
+
seg_mask_path = os.path.join(fish_vista_repo_dir, 'segmentation_masks/images')
|
207 |
+
|
208 |
+
# seg_id_trait_map.json maps the annotation id to the corresponding trait name.
|
209 |
+
# For example, pixels annotated with 1 correspond to the trait: 'Head'
|
210 |
+
id_trait_map_file = os.path.join(fish_vista_repo_dir, 'segmentation_masks/seg_id_trait_map.json')
|
211 |
+
with open(id_trait_map_file, 'r') as f:
|
212 |
+
id_trait_map = json.load(f)
|
213 |
+
|
214 |
+
# Read a segmentation csv file
|
215 |
+
train_path = os.path.join(fish_vista_repo_dir, 'segmentation_train.csv')
|
216 |
+
train_df = pd.read_csv(train_path)
|
217 |
+
|
218 |
+
# Get image and segmentation mask of image at index 'idx'
|
219 |
+
idx = 0
|
220 |
+
img_filename = train_df.iloc[idx].filename
|
221 |
+
img_mask_filename = os.path.splitext(img_filename)[0]+'.png'
|
222 |
+
# Load and view the mask
|
223 |
+
img_mask = Image.open(os.path.join(seg_mask_path, img_mask_filename))
|
224 |
+
plt.imshow(img_mask)
|
225 |
+
|
226 |
+
# List the traits that are present in this image
|
227 |
+
img_mask_arr = np.asarray(img_mask)
|
228 |
+
print([id_trait_map[str(trait_id)] for trait_id in np.unique(img_mask_arr)])
|
229 |
+
```
|
230 |
|
231 |
## Dataset Details
|
232 |
|