This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added .csv image loading utils (#116)
* added .csv image loading utils * added .csv image loading utils * added .csv image loading utils * added .csv image loading utils * added .csv image loading utils * added .csv image loading utils * added .csv image loading utils * added .csv image loading utils * added .csv image loading utils * added .csv image loading utils * added .csv image loading utils * added .csv image loading utils * added .csv image loading utils * added .csv image loading utils
- Loading branch information
1 parent
43b1aa0
commit 592b580
Showing
6 changed files
with
135 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,5 @@ docs/api/ | |
titanic.csv | ||
.vscode | ||
data_folder | ||
data | ||
*.pt | ||
*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,6 +158,7 @@ Available backbones: | |
* densenet121 | ||
* densenet169 | ||
* densenet161 | ||
* swav-imagenet | ||
|
||
------ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from flash.data.data_utils import labels_from_categorical_csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import Dict, List, Union | ||
|
||
import pandas as pd | ||
|
||
|
||
def labels_from_categorical_csv(csv: str, index_col: str, return_dict: bool = True) -> Union[Dict, List]: | ||
""" | ||
Returns a dictionary with {index_col: label} for each entry in the csv. | ||
Expects a csv of this form: | ||
index_col, b, c, d | ||
some_name, 0 0 1 | ||
some_name_b, 1 0 0 | ||
""" | ||
df = pd.read_csv(csv) | ||
# get names | ||
names = df[index_col].to_list() | ||
del df[index_col] | ||
|
||
# everything else is binary | ||
labels = df.to_numpy().argmax(1).tolist() | ||
|
||
if return_dict: | ||
labels = {name: label for name, label in zip(names, labels)} | ||
|
||
return labels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters