Package: wd14-tagger-api
A simple FastAPI Server to run WD1.4-TaggerFeel free to make PRs or use the code for your own needsChangelogYou can keep track of all changes on therelease pageInstallationSimple installation :pipinstallwd14-tagger-apiThis will install all the necessary dependencies, including aCPU support onlyversion of PyTorchI recommend that you install theGPU versionto improve processing speed.Don't forget to add the-d gpuflagNoteThe first startup using a video card may take a long time ( up to 30-60 seconds ) but then the result of processing will be almost minimalWindowspython-mvenvvenv
venv\Scripts\activate
pipinstallwd14-tagger-api
pipinstallonnxruntime-gpuLinuxpython-mvenvvenvsourcevenv\bin\activate
pipinstallwd14-tagger-api
pipinstallonnxruntime-gpuManual# Clone REPOgitclonehttps://github.com/daswer123/wd14-tagger-api-servercdwd14-tagger-api-server# Create virtual envpython-mvenvvenv
venv/scripts/activateorsourcevenv/bin/activate# Install depspipinstall-rrequirements.txt
pipinstallonnxruntime-gpu# Launch serverpython-mwd14_tagger_apiStarting Serverpython -m wd14_tagger_apiwill run on default ip and port (localhost:8019)usage: xtts_api_server [-h] [-hs HOST] [-p PORT] [-d DEVICE] [-wdm WD14 model] [-wdt WD14 threshold] [--replace-underscore]

Run WD14-Tagger within a FastAPI application

options:
  -h, --help show this help message and exit
  -hs HOST, --host HOST
  -p PORT, --port PORT
  -d DEVICE, --device DEVICE `cpu` or `gpu`
  -wdm WD14 Model, --wd14-model You can specify which model to use when loading the server.
  -wdt WD14 Threshold, --wd14-threshold  Threshold value for WD14
  --replace-underscore Will return spaces instead of underscoreAvalible Modelswd14-vit.v2wd14-vit.v2wd14-convnext.v1wd14-convnext.v2wd14-convnextv2.v1wd14-swinv2-v1wd-v1-4-moat-tagger.v2mld-caformer.dec-5-97527mld-tresnetd.6-30000API DocsAPI documentation can be accessed fromhttp://localhost:8002/docswhen the server is running. This documentation is automatically generated by FastAPI and provides an interactive interface to test the API endpoints.Endpoints OverviewThe server provides several endpoints related to image tagging functionality:POST/update-settings/This endpoint allows updating model settings dynamically.Request Body: JSON object containing new settings values.wd14_model: String (optional). The name of the model to use.threshold: Float (optional). The threshold value for tag generation.Example Request:{"wd14_model":"new-model-name","threshold":0.5}Response: A confirmation message indicating that settings have been updated successfully.POST/tag-image/Upload an image file to get associated tags based on current model and threshold settings.Form Data:file: File. Image file to be tagged.Response: A string of comma-separated tags generated for the uploaded image. IfWD14_REPLACE_UNDERSCOREenvironment variable is set to true, underscores in tags are replaced with spaces.Usage ExamplesBelow are examples usingcurlcommand-line tool to interact with the server:Updating Model Settingscurl-X'POST'\'http://localhost:8002/update-settings/'\-H'accept: application/json'\-H'Content-Type: application/json'\-d'{"wd14_model": "new-model-name", "threshold": 0.5}'Tagging an Imagecurl-X'POST'\'http://localhost:8002/tag-image/'\-H'accept: application/json'\-F'file=@path_to_your_image.jpg;type=image/jpeg'Replace"path_to_your_image.jpg"with the actual path to your image file you wish to tag.CreditThankscorkborgfor its standalone version, I used it as a base for the server.