Tried Running ERNIE-ViLG on Google Colaboratory
I came across an article stating that ERNIE-ViLG is strong with "2D characters". I tried to use it on the next page, but the response was not very good.
So, I thought I would write ERNIE-ViLG on Google Colaboratory, referring to the official page.
Running on Google Colaboratory
The thing I actually made is the following.
I honestly don't understand the contents well (I just tried it according to the official page), but I'll introduce it briefly.
Preparation
Run the following command to prepare ERNIE-ViLG. (It does not work without a GPU environment)
$ pip install paddlepaddle-gpu -U
$ pip install paddlehub==2.1.0
import paddlehub
paddlehub.server_check()
$ hub install ernie_vilg
Using ERNIE-ViLG
There are two patterns to use.
- Execute with CLI (hub command)
- Execute with Python (hub library)
In the case of CLI, it is as follows.
$ hub run ernie_vilg --text_prompts "A quiet town" --style "Oil painting" --output_dir ernie_vilg_out
In the case of Python, it is as follows.
import paddlehub as hub
module = hub.Module(name="ernie_vilg")
text_prompts = ["宁静的小镇"]
images = module.generate_image(text_prompts=text_prompts, style='油画', output_dir='./ernie_vilg_out/')
The options are as follows.
- text_prompts
- Input text describing the content of the image you want to generate
- style
- It is possible to generate images with style
- Oil painting
- Watercolor
- Pastel
- Cartoon
- For children
- Crayon
- Exploring infinity
- It is possible to generate images with style
- topk
- Number of images to generate (up to 6)
- output_dir
- Directory to save (default:ernievilg_output)
The text_prompts and style must be written in Chinese.
Easily View Images in Google Colaboratory
When you run ERNIE-ViLG, the output files go into a folder in Google Colaboratory. To view the images, you have to go through the hassle of downloading and opening them.
Therefore, there is a feature to sync the folder with Google Drive. If you use this, you can set the save destination to Google Drive and view the images from the UI of Google Drive.
It's incredibly convenient, so please give it a try.
Share
Related tags
- Stuck on the path in zod's refine
- Committing to Git from iPhone using Obsidian
- Useful Prompt Phrase Collection for Midjourney and StableDiffusion
- Trying to Integrate Dagger for CI/CD with GithubActions and CircleCI
- Trying out connect-web
- Thoughts on Using Ruby on Rails in Business
- It's become harder to "ask casually" since remote work started
- How to Set Up Your Antenna in Technology (Ride on the Shoulders of Giants!)
- Remote Debugging (Break Point) with IntelliJ + TypeScript + Docker
- Deploying Cloud Run in Just 3 Steps (golang)