huggingface / hub-docs

Docs of the Hugging Face Hub
http://hf.co/docs/hub
Apache License 2.0
297 stars 251 forks source link

Better page thumbnails: use first image by default #346

Open gwern opened 2 years ago

gwern commented 2 years ago

Hub pages should provide better image thumbnails for use in previews on social media websites like Twitter or Reddit. This can be done by a user-configurable setting, and by a heuristic of using the first image in a model/project README as the default image thumbnail.


A concrete example: Stable Diffusion models are very hot image generative models now, and there are ever more finetuned models and variations. They usually come with image samples that in a nutshell reveal their capabilities to interested users.

An example of such a project is pony-diffusion, whose README contains 4 sample images which show off its capabilities & 3 of which would be decent thumbnails (such as the first one). The current thumbnail is:

    <meta property="og:image" content="https://thumbnails.huggingface.co/social-thumbnails/models/AstraliteHeart/pony-diffusion.png" />

It is not decent (copying for posterity):

image

Aside from the text contents being redundant with the page title / URL, it is completely illegible as a thumbnail because there is too much text which is at least 10x too small to be read, to the point where I was staring at it on Reddit wondering what on earth this smudge was supposed to be and started thinking about how HF really ought to do better:

image

A simple improvement which I use successfully on my own sites, and which I copied from Wikipedia which uses it likewise in its thumbnail popups, would be to take the first <img> in the README and use that as the thumbnail. eg in pony-diffusion's case it'd read:

<meta property="og:image" content="https://cdn.discordapp.com/attachments/1020199895694589953/1020200601780494386/000001.553325548.png" />

This also makes it easy for users like AstraliteHeart to change it if they want to: just change the obvious first image in your README which has pride of place.

(If there is no image at all, I would still suggest changing the text-swirl default image to something more legible.)

julien-c commented 2 years ago

hi, thanks for your feedback.

As a quick fix , repo authors can set a custom social thumbnail in the model card metadata (also works for datasets and Spaces): for instance i've opened a pull request to do it here: https://huggingface.co/AstraliteHeart/pony-diffusion/discussions/2

diff --git a/README.md b/README.md
index 7076eac878fca52e33e4e2795b2b4b97c0a7781e..737fe439180252273b2f73c739281c56ff91ea5e 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ tags:
 - text-to-image
 license: bigscience-bloom-rail-1.0
 inference: false
-
+thumbnail: "https://cdn.discordapp.com/attachments/1020199895694589953/1020200601780494386/000001.553325548.png"
 ---

 # pony-diffusion - >nohooves
osanseviero commented 11 months ago

This has not been requested again and there is this solution, so will close this issue

juhoinkinen commented 1 month ago

hi, thanks for your feedback.

As a quick fix , repo authors can set a custom social thumbnail in the model card metadata (also works for datasets and Spaces): for instance i've opened a pull request to do it here: https://huggingface.co/AstraliteHeart/pony-diffusion/discussions/2

diff --git a/README.md b/README.md
index 7076eac878fca52e33e4e2795b2b4b97c0a7781e..737fe439180252273b2f73c739281c56ff91ea5e 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ tags:
 - text-to-image
 license: bigscience-bloom-rail-1.0
 inference: false
-
+thumbnail: "https://cdn.discordapp.com/attachments/1020199895694589953/1020200601780494386/000001.553325548.png"
 ---

 # pony-diffusion - >nohooves

It seems that currently the custom preview image for social shares does not work?

At least I don't get it working for juhoinkinen/Annif-webcam-ocr space, and also these test sites display no image for the AstraliteHeart/pony-diffusion model from above example PR:


Also, when I open the Metadata UI editor for a README.md file, there is "Upload file" button for a thumbnail (which on hover shows "The image that will be displayed when your space is shared on social media."):

Screenshot from 2024-10-11 17-23-28

However, when I try to use it to upload a file (~300 KB png), it gives only "Uploading..." prompt running indefinitely (on Firefox).

I don't find mentions of the local file upload feature in the Spaces Configuration Reference.

gary149 commented 1 month ago

Your image url doesn't seem to work: https://cdn.discordapp.com/attachments/1020199895694589953/1020200601780494386/000001.553325548.png

Also, when I open the Metadata UI editor for a README.md file, there is "Upload file" button for a thumbnail (which on hover shows "The image that will be displayed when your space is shared on social media."):

Trying to reproduce. edit: seems to work for me on Firefox: https://huggingface.co/spaces/victor/wikipedia-chatbot/commit/397b51eb5e5f20db9c2060680937d1aa7fa70eca

gary149 commented 1 month ago

Can you share your image @juhoinkinen? I'll try with it.

juhoinkinen commented 1 month ago

Thanks @gary149, but no need anymore!

I got the preview image working, when I used it from https://annif.org/static/img/annif-social.png, but previously I had used it from GitHub, and it did not work: https://huggingface.co/spaces/juhoinkinen/Annif-webcam-ocr/commit/9d77b253abfdd37d7db9933b44b0ee202fd6ddae

Sorry for the noise!