news2meme

所属分类:自动编程
开发工具:Python
文件大小:17KB
下载次数:0
上传日期:2022-04-27 11:23:55
上 传 者sh-1993
说明:  “News2meme:基于文本和图像的词子空间的新闻自动内容生成器”论文代码
(Code for the paper "News2meme: An Automatic Content Generator from News Based on Word Subspaces from Text and Image")

文件列表:
__pycache__ (0, 2022-04-27)
__pycache__\data.cpython-310.pyc (3988, 2022-04-27)
__pycache__\hottabasisvector.cpython-310.pyc (611, 2022-04-27)
__pycache__\settings.cpython-310.pyc (671, 2022-04-27)
__pycache__\subspace.cpython-310.pyc (3200, 2022-04-27)
data.py (3613, 2022-04-27)
download.sh (452, 2022-04-27)
environment.yaml (1765, 2022-04-27)
experiments (0, 2022-04-27)
experiments\gen_all.yaml (39, 2022-04-27)
experiments\gen_id.yaml (56, 2022-04-27)
experiments\gen_random.yaml (42, 2022-04-27)
experiments\gen_single.yaml (64, 2022-04-27)
experiments\train.yaml (26, 2022-04-27)
news2meme.py (6549, 2022-04-27)
sample (0, 2022-04-27)
sample\news.txt (975, 2022-04-27)
settings.py (689, 2022-04-27)
subspace.py (3539, 2022-04-27)
visualize.py (1858, 2022-04-27)

# news2meme This is the repository with the code for the paper "News2meme: An Automatic Content Generator from News Based on Word Subspaces from Text and Image". Small notes: - The work presented on the paper was obtained with a Matlab code which I cannot run because I do not have Matlab's license anymore. Therefore, I re-wrote everything in Python and I hope this change makes the project more accessible (even though it has been over three years since I published this paper ^^") - In the original code, I used pre-trained word2vec embeddings. However, in this repo, I opted for using pre-trained GLoVe just because it was a bit easier for me to work. I expect the results to be pretty similar for both. ## Installation 1. Clone this repo: ``` git clone https://github.com/ericashimomoto/news2meme.git cd news2meme ``` 2. Create a conda environment based on our dependecies and activate it: ``` conda env create -n --file environment.yaml conda activate ``` Where you can replace `` with whatever name you want. - Only got to test this code on Mac. It should run with not much trouble on Linux. I have no idea if it will run properly on Windows (sorry!). 3. Download everything: This script will download the following things in the folder `~/data/news2meme`: - The `glove.42B.300d.txt` pre-trained word embeddings. - The news2meme dataset, with the following structure and content: |-- news2meme |-- catchphrases |-- catchphrases.csv |-- memeimages |-- full: Folder with the original images. |-- memeImages.csv |-- news |-- full: Folder with the images available with each news article. |-- newsinlevels_level2.csv For News2meme, you don't actually need the images from the articles, but I included in the package as it might be useful for someone playing with the small dataset :) ### Configuration If you changed the download folder, make sure to change the path in settings.py ## Train Mode To be able to generate the memes, you first need to compute the subspaces for each meme image and each catchphrase in the dataset. To do this, run the following: `python news2meme.py --config=experiments/train.yaml` This code will save all the subspaces into the `OUTPUT_PATH` defined in `settings.py`. I set the contribution ratio to define the subspace dimensions to `0.5`, but feel free to change this value in the yaml file to see how it changes the results. ## Generation Mode You can generate memes in three different ways: 1. Free mode: Put your news article in a .txt file and modify the `experiments/gen_single.yaml` file with the path of the file in the `TEXT` field. Then, run the following: `python news2meme.py --config=experiments/gen_single.yaml` 2. Specific mode: Define the news article ID in the `experiments/gen_id.yaml` file in the `NEWS_ID` field. Then, run the following: `python news2meme.py --config=experiments/gen_id.yaml` 3. Random mode: Generate a meme for a randomly sampled news article. Run the following: `python news2meme.py --config=experiments/gen_random.yaml` 4. Full mode: Generate a meme for each news article in the database. Run the following: `python news2meme.py --config=experiments/gen_all.yaml` The news2meme will place a pickle file with the retrieved meme image and catchphrase id in the path specified by `OUTPUT_PATH` in `settings.py`. Again, I set the contribution ratio to be `0.8`, but feel free to change this value in the respective yaml files to see how it changes the results. ## Visualization To visualize the generated memes, run the following: `python visualize.py --result=output/gen_memes_ids.pickle` Where `output/gen_memes_ids.pickle` specifies the results generated by news2meme. The generated memes will be saved in the folder specified in field `VISUALIZATION_PATH` in `settings.py`. ## Citation If you use our code or dataset, please consider citing our work: ```bibtex @inproceedings{shimomoto2019news2meme, title={News2meme: An automatic content generator from news based on word subspaces from text and image}, author={Shimomoto, Erica K and Souza, Lincon S and Gatto, Bernardo B and Fukui, Kazuhiro}, booktitle={2019 16th International Conference on Machine Vision Applications (MVA)}, pages={1--6}, year={2019}, organization={IEEE} } ``` ## Questions? If you have any questions or problems while running this code, feel free to open an issue or to contact me at kidoshimomoto.e@aist.go.jp

近期下载者

相关文件


收藏者