├── AFPS └── download_asgan_dataset.sh ├── FLSS ├── flss.m ├── output │ ├── _1hdyytb1tmW1ZPfL3uG8g.x39.y509.a11.a2g.png │ ├── _2AeJdLdF_h8Rj4cmV8hZg.x529.y460.a-2.a2g.png │ └── _2oS3l8bDWwRA8BaYGDGvw.x93.y365.a19.a2g.png └── target │ ├── _1hdyytb1tmW1ZPfL3uG8g.x39.y509.a11.a2g.png │ ├── _2AeJdLdF_h8Rj4cmV8hZg.x529.y460.a-2.a2g.png │ └── _2oS3l8bDWwRA8BaYGDGvw.x93.y365.a19.a2g.png └── README.md /AFPS/download_asgan_dataset.sh: -------------------------------------------------------------------------------- 1 | FILE=$1 2 | 3 | if [[ $FILE != "CUFS" && $FILE != "CUFSF" && $FILE != "EPRIP" && $FILE != "PRIPVSGC" ]]; 4 | then echo "Available datasets are CUFS, CUFSF, EPRIP, PRIPVSGC" 5 | exit 1 6 | fi 7 | 8 | 9 | echo "Specified [$FILE]" 10 | 11 | URL=http://disi.unitn.it/~hao.tang/uploads/datasets/ASGAN/$FILE.tar.gz 12 | TAR_FILE=./AFPS/$FILE.tar.gz 13 | TARGET_DIR=./AFPS/$FILE/ 14 | wget -N $URL -O $TAR_FILE 15 | mkdir -p $TARGET_DIR 16 | tar -zxvf $TAR_FILE -C ./AFPS/ 17 | rm $TAR_FILE -------------------------------------------------------------------------------- /FLSS/flss.m: -------------------------------------------------------------------------------- 1 | close all; 2 | clear all; 3 | clc 4 | % -------------------------------------------------------------------- 5 | % Create image pair 6 | % -------------------------------------------------------------------- 7 | grondtruth_folder='/target'; 8 | generated_folder='/output'; 9 | 10 | grondtruth_jpg = dir( grondtruth_folder ); 11 | generated_jpg = dir( generated_folder ); 12 | fianlscore_da_db =[]; 13 | 14 | for i = 3 : length( grondtruth_jpg ) 15 | grondtruth_file = fullfile( grondtruth_folder, grondtruth_jpg( i ).name); 16 | generated_file = fullfile( generated_folder, generated_jpg( i ).name); 17 | 18 | % read image 19 | I_grondtruth = imread(grondtruth_file); 20 | I_generated = imread(generated_file); 21 | 22 | % -------------------------------------------------------------------- 23 | % Extract features and match 24 | % -------------------------------------------------------------------- 25 | 26 | [fa,da] = vl_sift(im2single(rgb2gray(I_grondtruth))) ; 27 | [fb,db] = vl_sift(im2single(rgb2gray(I_generated))) ; 28 | 29 | [matches, scores] = vl_ubcmatch(da,db) ; 30 | 31 | num_da = size(da,2); 32 | num_db = size(db,2); 33 | min_da_db = min(num_da,num_db); 34 | score_da_db(i-2) = size(matches,2)/min_da_db; 35 | 36 | da=[]; 37 | db=[]; 38 | matches=[]; 39 | end 40 | 41 | FLSS_Score = sum(score_da_db)/(length( grondtruth_jpg )-2) 42 | 43 | % -------------------------------------------------------------------- 44 | % Find the most similar pair 45 | % -------------------------------------------------------------------- 46 | [max_finalscore,index]=max(score_da_db); 47 | index=index+2; 48 | display(grondtruth_jpg( index ).name) 49 | grondtruth_file = fullfile( grondtruth_folder, grondtruth_jpg( index ).name); 50 | generated_file = fullfile( generated_folder, generated_jpg( index ).name); 51 | 52 | I_grondtruth = imread(grondtruth_file); 53 | I_generated = imread(generated_file); 54 | imshow(I_grondtruth) 55 | imshow(I_generated) 56 | [fa,da] = vl_sift(im2single(rgb2gray(I_grondtruth))) ; 57 | [fb,db] = vl_sift(im2single(rgb2gray(I_generated))) ; 58 | 59 | [matches, scores] = vl_ubcmatch(da,db) ; 60 | 61 | [drop, perm] = sort(scores, 'descend') ; 62 | matches = matches(:, perm) ; 63 | scores = scores(perm) ; 64 | 65 | figure(1) ; clf ; 66 | imagesc(cat(2, I_grondtruth, I_generated)) ; 67 | axis image off ; 68 | vl_demo_print('sift_match_1', 1) ; 69 | 70 | figure(2) ; clf ; 71 | imagesc(cat(2, I_grondtruth, I_generated)) ; 72 | 73 | xa = fa(1,matches(1,:)) ; 74 | xb = fb(1,matches(2,:)) + size(I_grondtruth,2) ; 75 | ya = fa(2,matches(1,:)) ; 76 | yb = fb(2,matches(2,:)) ; 77 | 78 | hold on ; 79 | h = line([xa ; xb], [ya ; yb]) ; 80 | set(h,'linewidth', 1, 'color', 'b') ; 81 | 82 | vl_plotframe(fa(:,matches(1,:))) ; 83 | fb(1,:) = fb(1,:) + size(I_grondtruth,2) ; 84 | vl_plotframe(fb(:,matches(2,:))) ; 85 | axis image off ; 86 | 87 | vl_demo_print('sift_match_2', 1) ; 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /FLSS/output/_1hdyytb1tmW1ZPfL3uG8g.x39.y509.a11.a2g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ha0Tang/ASGAN/d1a41fbb774fcd3d9045cef45462e320bf3635dc/FLSS/output/_1hdyytb1tmW1ZPfL3uG8g.x39.y509.a11.a2g.png -------------------------------------------------------------------------------- /FLSS/output/_2AeJdLdF_h8Rj4cmV8hZg.x529.y460.a-2.a2g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ha0Tang/ASGAN/d1a41fbb774fcd3d9045cef45462e320bf3635dc/FLSS/output/_2AeJdLdF_h8Rj4cmV8hZg.x529.y460.a-2.a2g.png -------------------------------------------------------------------------------- /FLSS/output/_2oS3l8bDWwRA8BaYGDGvw.x93.y365.a19.a2g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ha0Tang/ASGAN/d1a41fbb774fcd3d9045cef45462e320bf3635dc/FLSS/output/_2oS3l8bDWwRA8BaYGDGvw.x93.y365.a19.a2g.png -------------------------------------------------------------------------------- /FLSS/target/_1hdyytb1tmW1ZPfL3uG8g.x39.y509.a11.a2g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ha0Tang/ASGAN/d1a41fbb774fcd3d9045cef45462e320bf3635dc/FLSS/target/_1hdyytb1tmW1ZPfL3uG8g.x39.y509.a11.a2g.png -------------------------------------------------------------------------------- /FLSS/target/_2AeJdLdF_h8Rj4cmV8hZg.x529.y460.a-2.a2g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ha0Tang/ASGAN/d1a41fbb774fcd3d9045cef45462e320bf3635dc/FLSS/target/_2AeJdLdF_h8Rj4cmV8hZg.x529.y460.a-2.a2g.png -------------------------------------------------------------------------------- /FLSS/target/_2oS3l8bDWwRA8BaYGDGvw.x93.y365.a19.a2g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ha0Tang/ASGAN/d1a41fbb774fcd3d9045cef45462e320bf3635dc/FLSS/target/_2oS3l8bDWwRA8BaYGDGvw.x93.y365.a19.a2g.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![License CC BY-NC-SA 4.0](https://img.shields.io/badge/license-CC4.0-blue.svg)](https://github.com/Ha0Tang/ASGAN/blob/master/LICENSE.md) 2 | ![Python 3.6](https://img.shields.io/badge/python-3.6-green.svg) 3 | ![Packagist](https://img.shields.io/badge/Pytorch-0.4.1-red.svg) 4 | ![Last Commit](https://img.shields.io/github/last-commit/Ha0Tang/ASGAN) 5 | [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-blue.svg)](https://github.com/Ha0Tang/ASGAN/graphs/commit-activity) 6 | ![Contributing](https://img.shields.io/badge/contributions-welcome-red.svg?style=flat) 7 | ![Ask Me Anything !](https://img.shields.io/badge/Ask%20me-anything-1abc9c.svg) 8 | [![GitHub issues](https://img.shields.io/github/issues/Naereen/StrapDown.js.svg)](https://GitHub.com/Ha0Tang/ASGAN/issues/) 9 | 10 | # ASGAN 11 | Feature-Level Similarity Score (FLSS) and the proposed AFPS dataset for "[Attribute-Guided Sketch Generation (FG 19, Oral)](https://arxiv.org/abs/1901.09774)" by [Hao Tang](http://disi.unitn.it/~hao.tang/), Xinya Chen, [Wei Wang](https://weiwangtrento.github.io/), [Dan Xu](http://www.robots.ox.ac.uk/~danxu/), [Jason J. Corso](http://web.eecs.umich.edu/~jjcorso/), [Nicu Sebe](http://disi.unitn.it/~sebe/), [Yan Yan](https://userweb.cs.txstate.edu/~y_y34/). 12 | 13 | ## FLSS Metric 14 | 15 | ### Prerequisites 16 | - Matlab 17 | - VLFeat (download the latest binary package) 18 | 19 | ## AFPS dataset 20 | 21 | For CUFS, CUFSF, EPRIP or PRIPVSGC, the datasets must be downloaded beforehand. Please download them on the respective webpages. Please cite their papers if you use the data. 22 | 23 | You can download the corresponding attributed version using the following script. 24 | ``` 25 | git clone https://github.com/Ha0Tang/ASGAN 26 | cd ASGAN/ 27 | bash ./AFPS/download_asgan_dataset.sh dataset_name 28 | ``` 29 | 30 | - `CUFS`: 94 trianing, 94 testing. 31 | - `CUFSF`: 562 training, 561 testing. 32 | - `EPRIP`: 70 training, 16 testing. 33 | - `PRIPVSGC`: 70 training, 16 testing. 34 | 35 | 36 | ## Citation 37 | If you use this code or dataset for your research, please cite our paper. 38 | 39 | ``` 40 | @inproceedings{tang2019attribute, 41 | title={Attribute-Guided Sketch Generation}, 42 | author={Tang, Hao and Chen, Xinya and Wang, Wei and Xu, Dan and Corso, Jason J and Sebe, Nicu and Yan, Yan}, 43 | booktitle={FG}, 44 | year={2019} 45 | } 46 | ``` 47 | 48 | ## Acknowledgments 49 | This code borrows heavily from [VLFeat](http://www.vlfeat.org/). We acknowledge the National Institute of Standards and Technology Grant 60NANB17D191 for 50 | funding this research. We also acknowledge the gift donation from Cisco, Inc for this research. 51 | 52 | ## Related Projects 53 | 54 | **[SelectionGAN](https://github.com/Ha0Tang/SelectionGAN)** 55 | 56 | ## Contributions 57 | If you have any questions/comments/bug reports, feel free to open a github issue or pull a request or e-mail to the author Hao Tang ([bjdxtanghao@gmail.com](bjdxtanghao@gmail.com)). 58 | --------------------------------------------------------------------------------