TheHickman commited on
Commit
47603fc
·
verified ·
1 Parent(s): 56894c7

Prompt2Results

Browse files
Files changed (1) hide show
  1. app.py +107 -129
app.py CHANGED
@@ -81,17 +81,15 @@ TEXT_GENERATION = f"""
81
  <div id="hf-content" style="max-width: 800px; margin: auto; font-size: 16px; line-height: 1.6;">
82
  <h1>Text Generation (Hugging Face)</h1>
83
  <p>
84
- Text generation is like supercharged autocomplete. You type a few words, and the model continues the text.
85
- It can complete sentences, answer questions, rewrite text, or follow instructions like a helpful assistant.
86
  </p>
87
  {IMAGE_HTML}""" + """
88
  <h1>About Text Generation</h1>
89
  <p>
90
- This page covers two main types of models:
91
- <a href="https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads">text generation</a> (continue the text) and
92
- <a href="https://huggingface.co/models?other=text2text-generation&sort=downloads">text-to-text generation</a> (turn one text into another, like translate or summarize).
93
- Popular open models used for chat and instructions are also included.
94
- You can see a ranked list of open large language models
95
  <a href="https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard">here</a>.
96
  </p>
97
 
@@ -99,24 +97,24 @@ TEXT_GENERATION = f"""
99
 
100
  <h3>Instruction Models</h3>
101
  <p>
102
- Some models are tuned to follow everyday instructions, such as “Write a friendly email to my landlord.”
103
- Try open-access models like Mixtral 8x7B, Cohere Command R+, and Meta Llama 3 70B in
104
  <a href="https://huggingface.co/chat">Hugging Chat</a>.
105
  </p>
106
 
107
  <h3>Code Generation</h3>
108
  <p>
109
- Models can also help with coding by writing snippets from descriptions or continuing your code.
110
- StarCoder is a popular open model that can write code in many languages. Try it
111
  <a href="https://huggingface.co/spaces/bigcode/bigcode-playground">here</a>.
112
  </p>
113
 
114
  <h3>Story Writing</h3>
115
  <p>
116
- Give a starting line like “Once upon a time” and the model can continue with a story.
117
  Try a story-focused app by MosaicML
118
  <a href="https://huggingface.co/spaces/mosaicml/mpt-7b-storywriter">here</a>.
119
- If your needs are very specific, you can train a model from scratch. Learn how in the free Transformers
120
  <a href="https://huggingface.co/course/chapter7/6?fw=pt">course</a>.
121
  </p>
122
 
@@ -242,66 +240,54 @@ console.log(result.generated_text);
242
  </div>
243
  """
244
 
245
- QUESTION_ANSWER = f"""
246
  <div id="hf-content" style="max-width: 800px; margin: auto; font-size: 16px; line-height: 1.6;">
247
- <h1>Question Answering (Hugging Face)</h1>
248
  <p>
249
- Question Answering (QA) is about asking a question and getting an answer from text you provide.
250
- Think of it like using “find” in a digital book: you ask a question, and the tool scans the text to pull out the answer.
251
- Some QA systems can also answer without any text given, by writing an answer on their own.
252
  </p>
253
- {QA_IMAGE_HTML}"""+"""
254
- <h1>About Question Answering</h1>
255
 
256
- <h2>Use Cases</h2>
257
- <h3>Frequently Asked Questions</h3>
258
  <p>
259
- QA models can help automatically answer common questions by looking up information in a set of documents (your knowledge base).
260
- For example, a customer support bot can pull answers from product manuals or help center articles.
261
- ⚡⚡ To speed things up, you can first find the most relevant page or paragraph, then run QA only on that smaller piece.
262
- One way to do this is with <a href="https://huggingface.co/tasks/sentence-similarity">passage ranking</a> models that suggest where the answer is most likely to be.
263
  </p>
264
 
265
- <h2>Task Variants</h2>
266
  <p>
267
- There are a few ways QA can work, depending on what you give it and what you want back:
268
  <ul>
269
- <li><b>Extractive QA:</b> The model <b>picks</b> the answer from the text you provide (like highlighting a sentence in a document).
270
- The text could be a paragraph, a table, or even a web page.</li>
271
- <li><b>Open Generative QA:</b> You give some text as context, and the model <b>writes</b> the answer in its own words based on that text.</li>
272
- <li><b>Closed Generative QA:</b> You do <b>not</b> give any text. The model writes an answer from what it has learned before. (This can be helpful, but it can also guess or be wrong.)</li>
273
  </ul>
274
- The visual above shows the “open-book” style: you provide both a question and some text, and the model pulls the answer from that text.
275
- <br><br>
276
- Some models aim to handle any topic, while others are trained for a specific field (for example, law or medicine).
277
- Topic‑specific models can do better on their area but may struggle outside it.
278
  </p>
279
 
280
- <h2>What you need for good results</h2>
281
  <ul>
282
- <li><b>Clear questions:</b> Short, direct questions work best (“What is the refund period?”).</li>
283
- <li><b>Relevant context:</b> Provide text that actually contains the answer. If the answer isn’t there, extractive QA cannot find it.</li>
284
- <li><b>High‑quality sources:</b> Clean, uptodate documents lead to better answers.</li>
285
- <li><b>Right model for the job:</b> Use models that support your language and, if needed, your domain (e.g., legal, medical).</li>
286
- <li><b>Manage long documents:</b> Break long text into smaller parts or first pick the most relevant passage before running QA.</li>
287
- <li><b>Be specific:</b> If a question can mean many things, clarify it to reduce confusion.</li>
288
  </ul>
289
 
290
- <h2>Limits and common misconceptions</h2>
291
  <ul>
292
- <li><b>Extractive QA cannot invent answers:</b> If the text doesn’t contain the answer, it won’t magically appear.</li>
293
- <li><b>Generative QA can make things up:</b> When writing answers, models may sound confident but be wrong. Verify important facts.</li>
294
- <li><b>Not a web browser:</b> QA does not search the internet unless you connect it to a search or retrieval step.</li>
295
- <li><b>Confidence is not certainty:</b> A high score does not guarantee correctness; always sanity‑check critical outputs.</li>
296
- <li><b>Very long or messy input can confuse the model:</b> Short, relevant passages work better.</li>
297
- <li><b>Sensitive topics need human review:</b> For medical, legal, or safetycritical answers, involve an expert.</li>
298
  </ul>
299
 
300
- <h2>Inference</h2>
301
  <p>
302
- You can try QA with the 🤗 Transformers library using the question‑answering pipeline.
303
- If you don’t choose a specific model, it uses a small default one (distilbert-base-cased-distilled-squad).
304
- Give it a question and a piece of text that contains the answer, and it will return the answer span.
305
  </p>
306
  <pre style="background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;">
307
  from transformers import pipeline
@@ -318,62 +304,59 @@ print(result)
318
  </div>
319
  """
320
 
321
- SUMMARISATION = f"""
322
  <div id="hf-content" style="max-width: 800px; margin: auto; font-size: 16px; line-height: 1.6;">
323
- <h1>Summarisation (Hugging Face)</h1>
324
  <p>
325
- Summarisation means turning a long piece of text into a much shorter version that keeps the main ideas.
326
- Think of it like a movie trailer for an article: you get the key moments without watching the whole film.
327
- Some tools pick the most important sentences from the original text, while others rewrite the main points in their own words.
328
  </p>
329
- {SUMMARISATION_IMAGGE_HTML}""" + """
330
- <h1>About Summarisation</h1>
331
 
332
  <h2>Use Cases</h2>
333
- <h3>Research Paper Summarisation 🧐</h3>
334
  <p>
335
- Summaries of research papers help readers quickly decide what to read in full. You can approach this in a few simple ways:
336
  <ol>
337
- <li>Use an existing summariser from the Hugging Face Hub and run it as-is.</li>
338
- <li>Choose a model that works well on academic writing and, if needed, teach it with your own examples so it better matches your field.</li>
339
- <li>Use a model that rewrites content in its own words (for example, T5) to create clear, natural summaries.</li>
340
  </ol>
341
  Real-world examples:
342
- - A scientist gets a short overview of a 20-page paper before diving in.
343
- - A student creates a quick “abstract-style” note from lecture notes.
344
- - A librarian builds short descriptions for new entries in a repository.
345
  </p>
346
 
347
  <h3>What helps good performance</h3>
348
  <p>
349
  To get clear and reliable summaries:
350
  <ul>
351
- <li>Start with clean input: remove boilerplate (menus, ads, repeated footers).</li>
352
- <li>Match the model to your content type: news, scientific text, product reviews, etc.</li>
353
- <li>Give enough context: include the full section you want summarised, not just a fragment.</li>
354
- <li>Set the target length: decide if you want a headline, a paragraph, or a multi-paragraph summary.</li>
355
- <li>Use examples when possible: if you can, show the model examples of good summaries for your use case.</li>
356
  </ul>
357
- Analogy: If you want a great travel summary, give the guide your full itinerary and tell them how long the recap should be.
358
  </p>
359
 
360
  <h3>Limits and common misconceptions</h3>
361
  <p>
362
- Its important to know what summarisation can and cannot do:
363
  <ul>
364
- <li>May miss fine details: short summaries can skip edge cases, citations, or numbers.</li>
365
- <li>Can sound confident but be wrong: some models may introduce small mistakes or dates that werent in the text.</li>
366
- <li>Very long documents are hard: splitting into sections and summarising step by step often works better.</li>
367
- <li>Style matters: a model used to news articles may not do as well on legal or medical text without examples.</li>
368
- <li>Not a replacement for careful reading: dont rely on a summary alone for decisions with high stakes.</li>
369
  </ul>
370
- Common misconception: “The model truly understands the text.” In reality, it’s very good at pattern-matching and rewriting, but it doesn’t “know” like a human does.
371
  </p>
372
 
373
  <h3>Inference</h3>
374
  <p>
375
- You can use the 🤗 Transformers summarisation pipeline to run existing models.
376
- If you don’t provide a model name, it uses <a href="https://huggingface.co/sshleifer/distilbart-cnn-12-6">sshleifer/distilbart-cnn-12-6</a> by default.
377
  </p>
378
  <pre style="background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;">
379
  from transformers import pipeline
@@ -390,7 +373,7 @@ print(result)
390
  </pre>
391
 
392
  <p>
393
- You can also use <a href="https://github.com/huggingface/huggingface.js">huggingface.js</a> to run summarisation models hosted on Hugging Face Hub.
394
  </p>
395
  <pre style="background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;">
396
  import {{ InferenceClient }} from "@huggingface/inference";
@@ -412,87 +395,82 @@ await inference.summarization({{
412
 
413
  TEXT_2_IMAGGE = f"""
414
  <div id="hf-content" style="max-width: 800px; margin: auto; font-size: 16px; line-height: 1.6;">
415
- <h1>Text-to-Image (Hugging Face)</h1>
416
  <p>
417
- Text-to-image tools turn words into pictures. You describe what you want (like telling an artist), and the system creates an image from that description.
418
- These tools can also change existing photos by following simple written instructions.
419
  </p>
420
  {TEXT2IMAGE_IMAGE_HTML}
421
- <h1>About Text-to-Image</h1>
422
 
423
- <h2>What this can do</h2>
424
  <p>
425
- Think of it like giving directions to a skilled illustrator. You can ask for:
426
  </p>
427
  <ul>
428
- <li>Brand-new images made from a short sentence or detailed paragraph.</li>
429
- <li>Edits to your own photos (for example, “make the sky orange” or “add a cozy lamp on the table”).</li>
430
- <li>Variations on a theme (try different styles, moods, or times of day).</li>
431
  </ul>
432
 
433
- <h2>What you need for good results</h2>
434
  <ul>
435
- <li>Clear instructions: Mention the main subject, setting, style, and any key details. Start simple, then add specifics.</li>
436
- <li>Good input images (for editing): Sharp, well-lit photos make better edits.</li>
437
- <li>Right model choice: Some models are better at people, products, or certain art styles.</li>
438
- <li>Enough compute: A modern GPU speeds things up and can improve output size/quality.</li>
439
- <li>Iterate: Try a basic prompt first, look at the result, then refine your wording step by step.</li>
440
  </ul>
441
 
442
- <h2>Use Cases</h2>
443
- <h3>Data Generation</h3>
444
  <p>
445
- Companies can quickly create example images from text to plan ideas, test layouts, or fill prototypes without needing a photo shoot.
446
  </p>
447
- <h3>Immersive Conversational Chatbots</h3>
448
  <p>
449
- Chatbots can show helpful images on the fly (like “show me a cozy reading corner or “illustrate this recipe’s final dish”) to make conversations more engaging.
450
  </p>
451
- <h3>Creative Ideas for Fashion Industry</h3>
452
  <p>
453
- Designers can explore patterns, colors, and cuts before making real samples.
454
- It’s like sketching hundreds of options instantly to see what stands out.
455
  </p>
456
- <h3>Architecture Industry </h3>
457
  <p>
458
- Architects and interior designers can visualize rooms from rough descriptions (floor plans, style, furniture) to quickly explore different looks and layouts.
459
  </p>
460
 
461
- <h2>Task Variants</h2>
462
- <h3>Image Editing</h3>
463
  <p>
464
- You can change an image by writing simple instructions (for example, “turn it into sunset lighting or “add a plant next to the sofa”).
465
  <ul>
466
- <li><b>Synthetic image editing:</b> Editing images that were created by a model in the first place, while keeping the main idea the same.</li>
467
  </ul>
468
  {SYNTHETIC_HTML}
469
  <ul>
470
- <li>Real image editing: Editing real photos. This is often trickier because the model must match real-world lighting, texture, and detail.</li>
471
  </ul>
472
  {REAL_HTML}
473
  </p>""" + """
474
 
475
- <h3>Personalization</h3>
476
  <p>
477
- Personalization means teaching the system about a new subject (like your dog, your product, or your logo) using a few example photos.
478
- After that, you can ask for new images of that same subject in different scenes (for example, “my dog as an astronaut”).
479
- This can be done by briefly “learning” from your examples or by using lighter, training-free methods.
480
  </p>
481
 
482
- <h2>Limits and common misconceptions</h2>
483
  <ul>
484
- <li>Realism varies: Hands, text in images (like signs), and fine details can look odd or inaccurate.</li>
485
- <li>Consistency is hard: Getting the exact same character or object across many images can be difficult without personalization.</li>
486
- <li>Bias and gaps: Outputs reflect patterns in the data the model learned from and may contain bias or miss niche subjects.</li>
487
  <li>Not a search engine: It creates new images; it doesn’t pull exact photos from the internet.</li>
488
- <li>Resolution trade-offs: Very high-resolution images may need more steps or upscaling tools.</li>
489
- <li>Safety and rights: Avoid sharing sensitive images. Be mindful of copyrights, trademarks, and people’s privacy.</li>
490
  </ul>
491
 
492
- <h3>Inference</h3>
493
  <p>
494
- You can run text-to-image models locally with diffusers pipelines, or call them from the web.
495
- Try a short, simple prompt first. If the result is close, add details in small steps.
496
  </p>
497
  <pre style="background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;">
498
  from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
@@ -507,7 +485,7 @@ prompt = "a photo of an astronaut riding a horse on mars"
507
  image = pipe(prompt).images[0]
508
  </pre>
509
  <p>
510
- You can use <a href="https://github.com/huggingface/huggingface.js">huggingface.js</a> to run text-to-image models on Hugging Face Hub.
511
  </p>
512
  <pre style="background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;">
513
  import {{ InferenceClient }} from "@huggingface/inference";
 
81
  <div id="hf-content" style="max-width: 800px; margin: auto; font-size: 16px; line-height: 1.6;">
82
  <h1>Text Generation (Hugging Face)</h1>
83
  <p>
84
+ Imagine your phone's autocomplete feature, but much more advanced. That's what text generation is like. You start typing a few words, and the model, like a smart assistant, continues the text for you. It can finish your sentences, answer questions, rewrite text, or follow instructions.
 
85
  </p>
86
  {IMAGE_HTML}""" + """
87
  <h1>About Text Generation</h1>
88
  <p>
89
+ There are two main types of models for text generation:
90
+ <a href="https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads">text generation</a> (which continues the text you start) and
91
+ <a href="https://huggingface.co/models?other=text2text-generation&sort=downloads">text-to-text generation</a> (which changes one text into another, like translating or summarizing).
92
+ These models are also used for chatting and following instructions. You can find a list of popular models
 
93
  <a href="https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard">here</a>.
94
  </p>
95
 
 
97
 
98
  <h3>Instruction Models</h3>
99
  <p>
100
+ Some models are designed to follow everyday instructions, like “Write a friendly email to my landlord.”
101
+ You can try models like Mixtral 8x7B, Cohere Command R+, and Meta Llama 3 70B in
102
  <a href="https://huggingface.co/chat">Hugging Chat</a>.
103
  </p>
104
 
105
  <h3>Code Generation</h3>
106
  <p>
107
+ Models can also help with coding by writing code snippets from descriptions or continuing your code.
108
+ StarCoder is a popular model for writing code in many languages. Try it
109
  <a href="https://huggingface.co/spaces/bigcode/bigcode-playground">here</a>.
110
  </p>
111
 
112
  <h3>Story Writing</h3>
113
  <p>
114
+ Start with a line like “Once upon a time,” and the model can continue with a story.
115
  Try a story-focused app by MosaicML
116
  <a href="https://huggingface.co/spaces/mosaicml/mpt-7b-storywriter">here</a>.
117
+ If you have very specific needs, you can train a model from scratch. Learn how in the free Transformers
118
  <a href="https://huggingface.co/course/chapter7/6?fw=pt">course</a>.
119
  </p>
120
 
 
240
  </div>
241
  """
242
 
243
+ QUESTION_ANSWER = """
244
  <div id="hf-content" style="max-width: 800px; margin: auto; font-size: 16px; line-height: 1.6;">
245
+ <h1>Understanding Question Answering</h1>
246
  <p>
247
+ Imagine you have a big book and you want to find a specific piece of information. Instead of reading the whole book, you ask a question and a tool helps you find the answer quickly. This is what Question Answering (QA) does. It helps you get answers from a text you provide, like a digital assistant that reads for you.
 
 
248
  </p>
249
+ <h1>How Question Answering Works</h1>
 
250
 
251
+ <h2>Real-Life Uses</h2>
252
+ <h3>Answering Common Questions</h3>
253
  <p>
254
+ QA can be used to automatically answer questions people often ask. For example, a customer service chatbot can use QA to find answers in product manuals or help articles. To make it faster, you can first find the most relevant part of the text and then use QA on that smaller section.
 
 
 
255
  </p>
256
 
257
+ <h2>Different Ways QA Can Work</h2>
258
  <p>
259
+ QA can work in a few different ways, depending on what you give it and what you want:
260
  <ul>
261
+ <li><b>Extractive QA:</b> The tool finds the answer directly from the text you provide, like highlighting a sentence in a book.</li>
262
+ <li><b>Open Generative QA:</b> You give some text as a hint, and the tool writes the answer in its own words based on that text.</li>
263
+ <li><b>Closed Generative QA:</b> You don't give any text, and the tool writes an answer based on what it has learned before. This can be helpful, but it might also guess or be wrong.</li>
 
264
  </ul>
265
+ Some tools are designed to handle any topic, while others are better at specific subjects like law or medicine. Specialized tools can be more accurate in their field but might not work well outside it.
 
 
 
266
  </p>
267
 
268
+ <h2>Getting Good Results</h2>
269
  <ul>
270
+ <li><b>Ask Clear Questions:</b> Simple and direct questions work best, like “What is the refund period?”</li>
271
+ <li><b>Provide Relevant Text:</b> Make sure the text you give actually contains the answer. If it's not there, the tool can't find it.</li>
272
+ <li><b>Use Good Sources:</b> Clean and up-to-date documents lead to better answers.</li>
273
+ <li><b>Choose the Right Tool:</b> Use tools that support your language and, if needed, your specific topic.</li>
274
+ <li><b>Manage Long Texts:</b> Break long texts into smaller parts or find the most relevant section first.</li>
275
+ <li><b>Be Specific:</b> If a question can mean different things, clarify it to avoid confusion.</li>
276
  </ul>
277
 
278
+ <h2>Limits and Misunderstandings</h2>
279
  <ul>
280
+ <li><b>Extractive QA Can't Make Up Answers:</b> If the text doesn’t have the answer, it won’t appear magically.</li>
281
+ <li><b>Generative QA Might Guess:</b> When writing answers, the tool might sound sure but be wrong. Always check important facts.</li>
282
+ <li><b>Not a Web Search:</b> QA doesn’t search the internet unless you connect it to a search tool.</li>
283
+ <li><b>Confidence Isn’t Certainty:</b> A high score doesn’t mean the answer is correct; always double-check important outputs.</li>
284
+ <li><b>Long or Messy Text Can Confuse:</b> Short, clear passages work better.</li>
285
+ <li><b>Sensitive Topics Need Experts:</b> For medical, legal, or safety-critical answers, involve a human expert.</li>
286
  </ul>
287
 
288
+ <h2>Trying It Out</h2>
289
  <p>
290
+ You can try QA using a tool called the 🤗 Transformers library. If you don’t pick a specific tool, it uses a small default one. You give it a question and a piece of text with the answer, and it will find the answer for you.
 
 
291
  </p>
292
  <pre style="background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;">
293
  from transformers import pipeline
 
304
  </div>
305
  """
306
 
307
+ SUMMARISATION = """
308
  <div id="hf-content" style="max-width: 800px; margin: auto; font-size: 16px; line-height: 1.6;">
309
+ <h1>Summarization (Hugging Face)</h1>
310
  <p>
311
+ Summarization is like creating a short version of a long story. Imagine you watched a movie and then told a friend just the main parts in a few sentences. That's what summarization does with text. Some tools pick out the most important sentences, while others rewrite the main ideas in their own words.
 
 
312
  </p>
313
+ <h1>About Summarization</h1>
 
314
 
315
  <h2>Use Cases</h2>
316
+ <h3>Research Paper Summarization 🧐</h3>
317
  <p>
318
+ Summarizing research papers helps people quickly decide if they want to read the whole thing. Here are some simple ways to do it:
319
  <ol>
320
+ <li>Use a ready-made summarizer from Hugging Face and run it as it is.</li>
321
+ <li>Pick a model that works well with academic writing and, if needed, teach it with your own examples to make it better for your field.</li>
322
+ <li>Use a model that can rewrite content in its own words to make clear and natural summaries.</li>
323
  </ol>
324
  Real-world examples:
325
+ - A scientist gets a quick overview of a 20-page paper before reading it all.
326
+ - A student makes a short note from lecture notes.
327
+ - A librarian creates short descriptions for new books in a library.
328
  </p>
329
 
330
  <h3>What helps good performance</h3>
331
  <p>
332
  To get clear and reliable summaries:
333
  <ul>
334
+ <li>Start with clean text: remove unnecessary parts like menus or ads.</li>
335
+ <li>Choose the right model for your text type: news, science, product reviews, etc.</li>
336
+ <li>Provide enough context: include the full section you want summarized, not just a small part.</li>
337
+ <li>Decide the length: choose if you want a short headline, a paragraph, or a longer summary.</li>
338
+ <li>Use examples when possible: show the model examples of good summaries for your needs.</li>
339
  </ul>
340
+ Analogy: If you want a great travel summary, give the guide your full travel plan and tell them how long the recap should be.
341
  </p>
342
 
343
  <h3>Limits and common misconceptions</h3>
344
  <p>
345
+ It's important to know what summarization can and cannot do:
346
  <ul>
347
+ <li>May miss small details: short summaries might skip specific cases, references, or numbers.</li>
348
+ <li>Can sound confident but be wrong: some models might make small mistakes or add dates that weren't in the text.</li>
349
+ <li>Very long documents are tough: breaking them into sections and summarizing step by step often works better.</li>
350
+ <li>Style matters: a model used to news articles might not do well on legal or medical text without examples.</li>
351
+ <li>Not a replacement for careful reading: don't rely on a summary alone for important decisions.</li>
352
  </ul>
353
+ Common misconception: “The model truly understands the text.” In reality, it’s very good at finding patterns and rewriting, but it doesn’t “know” like a human does.
354
  </p>
355
 
356
  <h3>Inference</h3>
357
  <p>
358
+ You can use the 🤗 Transformers summarization tool to run existing models.
359
+ If you don’t provide a model name, it uses a default model called <a href="https://huggingface.co/sshleifer/distilbart-cnn-12-6">sshleifer/distilbart-cnn-12-6</a>.
360
  </p>
361
  <pre style="background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;">
362
  from transformers import pipeline
 
373
  </pre>
374
 
375
  <p>
376
+ You can also use <a href="https://github.com/huggingface/huggingface.js">huggingface.js</a> to run summarization models hosted on Hugging Face Hub.
377
  </p>
378
  <pre style="background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;">
379
  import {{ InferenceClient }} from "@huggingface/inference";
 
395
 
396
  TEXT_2_IMAGGE = f"""
397
  <div id="hf-content" style="max-width: 800px; margin: auto; font-size: 16px; line-height: 1.6;">
398
+ <h1>Turning Words into Pictures</h1>
399
  <p>
400
+ Imagine you could describe a scene to an artist, and they instantly paint it for you. That's what text-to-image tools do! You type out what you want to see, and the computer creates a picture based on your description. You can also use these tools to make changes to existing photos by giving simple instructions.
 
401
  </p>
402
  {TEXT2IMAGE_IMAGE_HTML}
403
+ <h1>Understanding Text-to-Image Tools</h1>
404
 
405
+ <h2>What Can These Tools Do?</h2>
406
  <p>
407
+ Think of these tools as a digital artist at your service. You can ask them to:
408
  </p>
409
  <ul>
410
+ <li>Create brand-new images from a short sentence or a detailed paragraph.</li>
411
+ <li>Edit your own photos, like changing the color of the sky or adding a lamp to a table.</li>
412
+ <li>Try different styles or moods, like making a picture look like a sunny day or a rainy night.</li>
413
  </ul>
414
 
415
+ <h2>How to Get Good Results</h2>
416
  <ul>
417
+ <li>Be clear with your instructions: Mention the main subject, setting, style, and any important details. Start simple, then add more specifics.</li>
418
+ <li>Use good quality photos for editing: Clear and well-lit photos work best.</li>
419
+ <li>Choose the right tool: Some tools are better at creating images of people, products, or specific art styles.</li>
420
+ <li>Have a powerful computer: A modern computer can make the process faster and improve the quality of the images.</li>
421
+ <li>Experiment: Start with a basic idea, see the result, and then refine your description step by step.</li>
422
  </ul>
423
 
424
+ <h2>Real-World Uses</h2>
425
+ <h3>Creating Sample Images</h3>
426
  <p>
427
+ Businesses can quickly make example images from text to plan ideas, test layouts, or create prototypes without needing a photo shoot.
428
  </p>
429
+ <h3>Interactive Chatbots</h3>
430
  <p>
431
+ Chatbots can show helpful images during conversations, like illustrating a cozy reading corner or a recipe’s final dish, making interactions more engaging.
432
  </p>
433
+ <h3>Fashion Design</h3>
434
  <p>
435
+ Fashion designers can explore different patterns, colors, and styles before making real samples. It's like sketching hundreds of options instantly to see what stands out.
 
436
  </p>
437
+ <h3>Architecture and Interior Design</h3>
438
  <p>
439
+ Architects and interior designers can visualize rooms from rough descriptions, like floor plans or furniture styles, to quickly explore different looks and layouts.
440
  </p>
441
 
442
+ <h2>Different Ways to Use These Tools</h2>
443
+ <h3>Editing Images</h3>
444
  <p>
445
+ You can change an image by writing simple instructions, like turning it into sunset lighting or adding a plant next to the sofa.
446
  <ul>
447
+ <li><b>Editing Computer-Generated Images:</b> Changing images that were created by the tool itself, while keeping the main idea the same.</li>
448
  </ul>
449
  {SYNTHETIC_HTML}
450
  <ul>
451
+ <li>Editing Real Photos: Changing real photos can be trickier because the tool must match real-world lighting, texture, and detail.</li>
452
  </ul>
453
  {REAL_HTML}
454
  </p>""" + """
455
 
456
+ <h3>Personalizing Images</h3>
457
  <p>
458
+ Personalization means teaching the tool about a new subject, like your pet or a product, using a few example photos. After that, you can ask for new images of that subject in different scenes, like your dog as an astronaut.
 
 
459
  </p>
460
 
461
+ <h2>Limits and Misunderstandings</h2>
462
  <ul>
463
+ <li>Realism can vary: Hands, text in images (like signs), and fine details might look odd or inaccurate.</li>
464
+ <li>Consistency is tough: Getting the exact same character or object across many images can be difficult without personalization.</li>
465
+ <li>Bias and gaps: The images reflect patterns in the data the tool learned from and may contain bias or miss niche subjects.</li>
466
  <li>Not a search engine: It creates new images; it doesn’t pull exact photos from the internet.</li>
467
+ <li>Resolution trade-offs: Very high-resolution images may need more steps or special tools to improve quality.</li>
468
+ <li>Safety and rights: Be careful with sensitive images and respect copyrights, trademarks, and people’s privacy.</li>
469
  </ul>
470
 
471
+ <h3>How to Use These Tools</h3>
472
  <p>
473
+ You can use text-to-image tools on your computer or through the internet. Start with a short, simple idea. If the result is close to what you want, add more details in small steps.
 
474
  </p>
475
  <pre style="background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;">
476
  from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
 
485
  image = pipe(prompt).images[0]
486
  </pre>
487
  <p>
488
+ You can also use <a href="https://github.com/huggingface/huggingface.js">huggingface.js</a> to run text-to-image models on Hugging Face Hub.
489
  </p>
490
  <pre style="background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;">
491
  import {{ InferenceClient }} from "@huggingface/inference";