Create a Personalized AI Portrait on Huawei Cloud ModelArts in 5 Simple Steps
This step‑by‑step guide shows how to use Huawei Cloud ModelArts and the U‑2‑Net AI model to create a personalized portrait for Valentine’s Day, covering account registration, environment configuration, data and code download, dependency installation, generation, and result display.
Valentine’s Day is approaching, and you can surprise your loved one with a custom AI‑generated portrait using Huawei Cloud ModelArts.
Step 1: Environment Setup
Enter the U‑2‑Net portrait generation page on ModelArts and configure the environment. The case uses PyTorch 1.4.0 and a GPU.
Framework: PyTorch 1.4.0
Hardware: GPU
Select the GPU specification if it defaults to CPU.
Step 2: Download Data and Code
Select the code and run each block with the triangle run button or press Ctrl+Enter. After successful execution, the code appears and the interface shows progress.
Step 3: Install Dependencies
Run the dependency‑installation cell; successful execution displays the output.
Step 4: Generate the Portrait
Run the generation cell to produce the portrait.
Step 5: View Results
Replace the input photo in the two indicated locations to see the before‑and‑after results.
import matplotlib.pyplot as
from PIL import Image
if __name__ == '__main__':
img = Image.open('./test_data/test_portrait_images/portrait_im/image.png')
transfer_img = Image.open('./test_data/test_portrait_images/portrait_results/image.png')
plt.figure(figsize=(10,10)) # set window size
plt.subplot(2, 2, 1) # two rows, two columns
plt.imshow(img)
plt.subplot(2, 2, 2) # two rows, two columns
plt.imshow(transfer_img)
plt.show()The whole process requires no prior AI experience; just follow the prompts to deliver a unique Valentine’s gift.
Huawei Cloud Developer Alliance
The Huawei Cloud Developer Alliance creates a tech sharing platform for developers and partners, gathering Huawei Cloud product knowledge, event updates, expert talks, and more. Together we continuously innovate to build the cloud foundation of an intelligent world.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
