How to Run ERNIE-ViLG AI Art Generator in Google Colab Free

How to Run ERNIE-ViLG AI Art Generator in Google Colab Free
Prompt: “a giant gundam japanese robot battlemech in city ruins, overtaken by vegetation, concept”

ERNIE-ViLG is a new state-of-the-art text-to-image AI art generation model, that was recently released by Baidu.

It’s difficult to compare ERNIE-ViLG to Stable Diffusion because the model is Chinese. You can give it prompts in English, and it will first translate them to Chinese, and then start the image generation. So comparing it using the exact English prompt doesn’t seem like a fair comparison. You can check more examples on Github to get a better idea.

Given that it’s developed by Baidu, we can definitely assume it will improve in the near future, and since it’s open-source we’ll be seeing a lot of advanced implementations.

You can easily test it on Hugging Face https://huggingface.co/spaces/PaddlePaddle/ERNIE-ViLG.

In this tutorial we’ll take the demo from Hugging Face and run it on Google Colab. This way you can generate images faster than by using the Hugging Face Spaces Demo, and you can also check the actual image generation progress.

Credit to 1littlecoder on YouTube for creating a tutorial on how to take HuggingFace demos very easily and use them in Colab.

Quick Demo of ERNIE-ViLG Running on Colab

Example Results & Prompt Design

These are some of my results with ERNIE-ViLG. I think it’s great and I wish I knew Chinese to better use it.

 

You can find some info regarding prompts in their docs page, where it also has a section on prompts. It should give you a few clues on how to better write prompts for ERNIE-VilG.

It also links to prompt tips for DALL-E 2, prompt tips for Disco Diffusion, and Aesthetics Wiki. This suggests that perhaps it works in a similar way.

The example prompts do seem a bit similar to the ones used for Disco Diffusion.

Copy the ERNIE-ViLG HuggingFace Spaces Demo on Google Colab

To copy the Hugging Face space on our Colab, follow these steps:

  1. Open a new Google Colab. You can just go here https://colab.research.google.com/ and a popup should appear with some options on what you files you want to open. Just click New notebook at the bottom.

    Open a New Notebook in Google Colab
    Open a New Notebook in Google Colab
  2. Paste the following code in any cell and run it. This will download the Hugging Face space onto your Colab, and then it will install ERNIE-ViLG’s dependencies. It should be just a few minutes.
    !git clone https://huggingface.co/spaces/PaddlePaddle/ERNIE-ViLG
    %cd ERNIE-ViLG
    !pip install -r requirements.txt -q
    !pip install gradio -q
  3. Next we want to edit the app.py file.
    1. Open the file browser on the left of Google Colab, expand the ERNIE-ViLG directory, and double click app.py. This will open the file on your right.
    2. Scroll to the bottom and change block.queue(concurrency_count=128).launch() to block.queue(concurrency_count=128).launch(share=True).
    3. Then press Ctrl+S to save the file.

    Editing the app.py File
    Editing the app.py File
  4. Finally just run !python app.py in another cell and wait ~1 minute.
  5. After it’s done you’ll see some URLs generated. Click on the public URL. It should end with .gradio.app.

    Access ERNIE-ViLG Gradio User Interface
    Access ERNIE-ViLG Gradio User Interface
  6. That’s it! Now you can start using ERNIE-ViLG in your browser.

    ERNIE-ViLG Web Interface
    ERNIE-ViLG Web Interface

Additional Notes

Where Can I See Image Generation Progress?

While generating you can check back in the Google Colab, and you’ll be able to see the image generation progress in the output for the last cell you ran.

View ERNIE-ViLG Progress
View ERNIE-ViLG Progress

Given the popularity of The Witcher franchise, you’d expect more accurate results. Perhaps we’ll find out later on what it was trained on so that it missed Geralt of Rivia.

Trying to generate Geralt of Rivia with ERNIE-ViLG
Trying to generate Geralt of Rivia with ERNIE-ViLG

Conclusion

In this tutorial we set up the ERNIE-ViLG Hugging Face Space on our Google Colab to create AI generated images free and faster.

We’re looking forward to seeing how this model will evolve. Since it’s developed by Baidu we can probably expect some amazing developments in the near future.

If you have any questions or have encountered any issues please feel free to leave a comment.


Resources & Acknowledgements

0 Shares:
Subscribe
Notify of
guest
Receive notifications when your comment receives a reply. (Optional)
Your username will link to your website. (Optional)

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
You May Also Like