gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
30.73k stars 2.29k forks source link

Feature request: features to enable custom preprocessing functions in Examples component #8365

Closed jyh2378 closed 1 month ago

jyh2378 commented 1 month ago

Is your feature request related to a problem? Please describe.
When using the Examples component with an image file, it can preview a thumbnail of the image in the app. Similarly, I'd like to add the ability to show a thumbnail of the first page of a PDF. However, the current Gradio Examples feature doesn't seem to be able to do it.

Describe the solution you'd like
I think it would be nice to allow the user to put in a custom preprocessing function before the values in examples are put into inputs. If there is such a feature, I think we could solve this problem by taking the path to the PDF file, changing the first page of the PDF to image and putting it into a gradio Image component.

Additional context

image

(3rd image is PDF file. I want to show the thumbnail as first page of pdf file)

abidlabs commented 1 month ago

Hi @jyh2378 you can check out the gradio_pdf custom component (https://huggingface.co/spaces/freddyaboulton/gradio_pdf) which supports this!