Added medium images to result data
Added json files to gitignore Updated documentation
This commit is contained in:
parent
aff8574356
commit
569d1abd1c
|
@ -1 +1,2 @@
|
||||||
.env
|
.env
|
||||||
|
*.json
|
29
README.md
29
README.md
|
@ -2,10 +2,35 @@
|
||||||
|
|
||||||
This repository contains scripts to search for Magic: The Gathering cards by image contents.
|
This repository contains scripts to search for Magic: The Gathering cards by image contents.
|
||||||
|
|
||||||
## generate-card-captions.js
|
#### generate-card-captions.js
|
||||||
|
|
||||||
This script takes a JSON file from scryfall.com containing card data. It generates a JSON file containing card names, IDs, and captions for each card. The captions are generated using Azure Cognitive Services Computer Vision API.
|
This script takes a JSON file from scryfall.com containing card data. It generates a JSON file containing card names, IDs, and captions for each card. The captions are generated using Azure Cognitive Services Computer Vision API.
|
||||||
|
|
||||||
## search-cards.js
|
#### search-cards.js
|
||||||
|
|
||||||
This script takes the output of generate-card-captions.js and searches the card captions for keywords provided and outputs another JSON file containing the results.
|
This script takes the output of generate-card-captions.js and searches the card captions for keywords provided and outputs another JSON file containing the results.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- Node.js
|
||||||
|
- Azure Cognitive Services Computer Vision API key and endpoint
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
1. Clone the repository.
|
||||||
|
2. Run `npm install` to install dependencies.
|
||||||
|
3. Obtain card data as JSON from [scryfall](https://scryfall.com/docs/api/bulk-data). Data should be an array of card objects as defined by the [scryfall API docs](https://scryfall.com/docs/api/cards)
|
||||||
|
4. Create a `.env` file in the root directory with the following contents:
|
||||||
|
|
||||||
|
```
|
||||||
|
AZURE_VISION_RESOURCE_URL=https://<your-resource-url>.cognitiveservices.azure.com/
|
||||||
|
AZURE_VISION_SUBSCRIPTION_KEY=<your-subscription-key>
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Run `node generate-card-captions.js -i <path_to_scryfall_data.json>` to generate card captions.
|
||||||
|
|
||||||
|
1. Add `-o <output_file.json>` to specify an output file.
|
||||||
|
2. Add `-a <api_version>` to specify the Azure Cognitive Services API version.
|
||||||
|
3. Add `-m <model_version>` to specify the Azure Cognitive Services model version.
|
||||||
|
|
||||||
|
6. If you want to search generated captions, currently you must modify `search-cards.js` to include the keywords you want to search for. Then run `node search-cards.js` to search the captions. Maybe I'll add command line arguments for this in the future, idk. Alternatively, check out the [MTG Visual Search Web App](http://nuc2:3000/henry/mtg-visual-search) for a clean interface to search for cards.
|
||||||
|
|
|
@ -43,6 +43,8 @@ let simpleCardArray = largeImages.map((card) => {
|
||||||
id: card.id,
|
id: card.id,
|
||||||
oracleId: card.oracle_id,
|
oracleId: card.oracle_id,
|
||||||
url: card.scryfall_uri,
|
url: card.scryfall_uri,
|
||||||
|
mediumImageUrl:
|
||||||
|
card.image_uris.normal || card.image_uris.small || card.image_uris.large,
|
||||||
caption: null,
|
caption: null,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue