Deploying AI Comic Factory via Hugging Face Inference API

Hugging Face has released a tutorial on deploying the AI Comic Factory to a private Space using the Inference API. This allows users to avoid long wait times associated with the public Space by leveraging their own Hugging Face PRO account to access high-performance models.

AI Comic Factory Architecture

The AI Comic Factory is built as a NextJS application deployed via Docker. Unlike standard Hugging Face Spaces, it utilizes a client-server architecture that relies on two distinct APIs to generate content:

  • Language Model API: Currently utilizes Llama-2 for text generation and story structuring.
  • Stable Diffusion API: Currently utilizes SDXL 1.0 for image generation.

Deployment Process via Space Duplication

Users can deploy their own version of the AI Comic Factory by duplicating the existing Space. Because the application runs within a Docker container and does not perform the heavy lifting locally, it can be hosted on the smallest available CPU instance. The official public Space uses a larger instance to handle high traffic volumes.

To successfully operate the duplicated Space, users must configure their Hugging Face token within the environment settings.

Backend Engine Configuration

The AI Comic Factory supports multiple backend engines, which are managed through two specific environment variables:

  • LLM_ENGINE: Configures the language model. Supported values include INFERENCE_API, INFERENCE_ENDPOINT, and OPENAI.
  • RENDERING_ENGINE: Configures the image generation engine. Supported values include INFERENCE_API, INFERENCE_ENDPOINT, REPLICATE, and VIDEOCHAIN.

For a standard deployment using the Hugging Face Inference API, both variables must be set to INFERENCE_API.

Pre-configured Model Defaults

For users with a Hugging Face PRO account, the AI Comic Factory comes with the following models pre-configured for the Inference API:

  • LLM Model: meta-llama/Llama-2-70b-chat-hf (via LLM_HF_INFERENCE_API_MODEL)
  • Rendering Model: stabilityai/stable-diffusion-xl-base-1.0 (via RENDERING_HF_RENDERING_INFERENCE_API_MODEL)

Current Limitations and Future Scope

While the Inference API integration is functional, it is in the early stages of development. Certain advanced features have not yet been ported to this deployment method, specifically the SDXL refiner step and image upscaling capabilities.

Sources