Deploying the AI Comic Factory using the Inference API

-


ARCHIVED ACCOUNT's avatar


We recently announced Inference for PROs, our latest offering that makes larger models accessible to a broader audience. This chance opens up latest possibilities for running end-user applications using Hugging Face as a platform.

An example of such an application is the AI Comic Factory – a Space that has proved incredibly popular. Hundreds of users have tried it to create their very own AI comic panels, fostering its own community of normal users. They share their creations, with some even opening pull requests.

On this tutorial, we’ll show you learn how to fork and configure the AI Comic Factory to avoid long wait times and deploy it to your personal private space using the Inference API. It doesn’t require strong technical skills, but some knowledge of APIs, environment variables and a general understanding of LLMs & Stable Diffusion are really useful.



Getting began

First, be sure that you enroll for a PRO Hugging Face account, as this can grant you access to the Llama-2 and SDXL models.



How the AI Comic Factory works

The AI Comic Factory is a bit different from other Spaces running on Hugging Face: it’s a NextJS application, deployed using Docker, and relies on a client-server approach, requiring two APIs to work:

  • a Language Model API (Currently Llama-2)
  • a Stable Diffusion API (currently SDXL 1.0)



Duplicating the Space

To duplicate the AI Comic Factory, go to the Space and click on “Duplicate”:

duplicate-space-1.jpg

You may observe that the Space owner, name, and visibility are already filled in for you, so you may leave those values as is.

Your copy of the Space will run inside a Docker container that does not require many resources, so you should use the smallest instance. The official AI Comic Factory Space utilizes a much bigger CPU instance, because it caters to a big user base.

To operate the AI Comic Factory under your account, you want to configure your Hugging Face token:

duplicate-space-2.jpg



Choosing the LLM and SD engines

The AI Comic Factory supports various backend engines, which will be configured using two environment variables:

  • LLM_ENGINE to configure the language model (possible values are INFERENCE_API, INFERENCE_ENDPOINT, OPENAI)
  • RENDERING_ENGINE to configure the image generation engine (possible values are INFERENCE_API, INFERENCE_ENDPOINT, REPLICATE, VIDEOCHAIN).

We’ll deal with making the AI Comic Factory work on the Inference API, in order that they each should be set to INFERENCE_API:

duplicate-space-3.jpg

You’ll find more details about alternative engines and vendors within the project’s README and the .env config file.



Configuring the models

The AI Comic Factory comes with the next models pre-configured:

  • LLM_HF_INFERENCE_API_MODEL: default value is meta-llama/Llama-2-70b-chat-hf
  • RENDERING_HF_RENDERING_INFERENCE_API_MODEL: default value is stabilityai/stable-diffusion-xl-base-1.0

Your PRO Hugging Face account already gives you access to those models, so that you do not have anything to do or change.



Going further

Support for the Inference API within the AI Comic Factory is in its early stages, and a few features, resembling using the refiner step for SDXL or implementing upscaling, have not been ported over yet.

Nonetheless, we hope this information will enable you to begin forking and tweaking the AI Comic Factory to fit your requirements.

Be happy to experiment and take a look at other models from the community, and blissful hacking!



Source link

ASK ANA

What are your thoughts on this topic?
Let us know in the comments below.

0 0 votes
Article Rating
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Share this article

Recent posts

0
Would love your thoughts, please comment.x
()
x