CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
huggingface

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: huggingface/notebooks
Path: blob/main/course/fr/chapter9/section2.ipynb
Views: 2548
Kernel: Python 3

Construire votre première démo

Installez les bibliothèques 🤗 Transformers et 🤗 Gradio pour exécuter ce notebook.

!pip install datasets transformers[sentencepiece] !pip install gradio
import gradio as gr def greet(name): return "Bonjour " + name demo = gr.Interface(fn=greet, inputs="text", outputs="text") demo.launch()
import gradio as gr def greet(name): return "Bonjour " + name # Nous instancions la classe Textbox textbox = gr.Textbox(label="Tapez votre nom ici :", placeholder="Marie Martin", lines=2) gr.Interface(fn=greet, inputs=textbox, outputs="text").launch()
from transformers import pipeline model = pipeline("text-generation", model="asi/gpt-fr-cased-small") def predict(prompt): completion = model(prompt)[0]["generated_text"] return completion
import gradio as gr gr.Interface(fn=predict, inputs="text", outputs="text").launch()