BEIJING — A Chinese museum has pulled a photo exhibition showing African faces juxtaposed with those of wild animals, after being accused of racism.

And if that wasn’t embarrassing enough, the country’s main social media messaging service was forced to apologize because its automatic translation bot was translating the term for “black foreigner” into the n-word.

These aren’t the first such incidents of their kind either. Last year, a Chinese detergent TV advertisement went viral and sparked international outrage after it showed an African man being transformed by a washing machine into a fresh-faced Chinese man.

Africans face considerable racism inside China, and the latest incidents underline just how slowly attitudes are changing. That’s a problem for the Chinese government too — it spends considerable financial and diplomatic capital wooing African leaders and African nations, but evidence of racist attitudes within China is bound to fuel mistrust.

The museum in the city of Wuhan had shown a dozen photographs of Africans next to animals showing similar facial expressions as part of an exhibition titled “This is Africa” by photographer Yu Huiping.

The Shanghaist website called the exhibition “incredibly racist.” It also quoted the president of the China Photographic Publishing House, Zhao Yingxin, as giving it a rave review, for “capturing the vitality of primitive life.”

The museum was forced into a rethink after Nigerian Instagram user Edward E. Duke (eddydizzle) posted a video of the exhibit and asked why “China put pictures of a particular race next to wild animals.” The Shanghaist reported that the Instagram post was later deleted.

Exhibition organizer Wang Yuejun said Chinese tradition, idioms and the zodiac often implied a relationship between people and animals, such as the phrase “as energetic as the dragon and the horse.”

But after some Africans said the photographs had hurt their feelings, he said they were pulled from the exhibition, out of respect for the views of our “African friends.”

The 12 photographs were in a part of the exhibit entitled “The face is the index of the heart.”

Meanwhile, the Wechat social messaging service, was also forced to apologize after it emerged that it was translating the term “hei laowei” into the n-word, especially if the context was negative. The website gave some examples, showing the bot used the n-word especially in sentences that meant the black foreigner was late, or was a thief.

The translation bot was subsequently altered to always use the term “black foreigner.”

“We’re very sorry for the inappropriate translation,” a WeChat spokesperson told the Sixth Tone website. “After receiving users’ feedback, we immediately fixed the problem.”

China’s outreach to Africa has won it many friends on the continent, but there is also resentment at the use of Chinese rather than Africa workers in some projects, as well as over rampant elephant poaching to supply China’s trade in ivory.

A Chinese laundry detergent ad went viral and has prompted backlash for its racist implications. (Thomas Johnson/The Washington Post)

Yang Liu contributed to this report.