Spaces:
Running
Running
add howto
Browse files
app.py
CHANGED
@@ -79,7 +79,50 @@ In addition to text tasks, 🙏🏻PLeIAs/📸📈✍🏻Florence-PDF also incor
|
|
79 |
|
80 |
joinus = """🌟TeamTonic🌟 is always making cool demos! Join our active builder's 🛠️community 👻 [](https://discord.gg/qdfnvSPcqP) On 🤗Huggingface:[MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to🌟 [Build Tonic](https://git.tonic-ai.com/contribute)🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
|
81 |
"""
|
|
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
84 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
85 |
|
@@ -131,7 +174,7 @@ def plot_bbox(image, data, use_quad_boxes=False):
|
|
131 |
plt.text(x1, y1, label, color='white', fontsize=8, bbox=dict(facecolor='red', alpha=0.5))
|
132 |
|
133 |
ax.axis('off')
|
134 |
-
|
135 |
return fig
|
136 |
|
137 |
def draw_ocr_bboxes(image, prediction):
|
@@ -227,7 +270,7 @@ with gr.Blocks(title="Tonic's 🙏🏻PLeIAs/📸📈✍🏻Florence-PDF") as if
|
|
227 |
with gr.Group():
|
228 |
gr.Markdown(description)
|
229 |
with gr.Row():
|
230 |
-
with gr.Accordion("Join Us", open=True):
|
231 |
gr.Markdown(joinus)
|
232 |
with gr.Row():
|
233 |
with gr.Column(scale=1):
|
@@ -237,6 +280,8 @@ with gr.Blocks(title="Tonic's 🙏🏻PLeIAs/📸📈✍🏻Florence-PDF") as if
|
|
237 |
submit_button = gr.Button("📸📈✍🏻Process")
|
238 |
reset_button = gr.Button("♻️Reset")
|
239 |
with gr.Accordion("🧪Advanced Settings", open=False):
|
|
|
|
|
240 |
top_k = gr.Slider(minimum=1, maximum=100, value=50, step=1, label="Top-k")
|
241 |
top_p = gr.Slider(minimum=0.0, maximum=1.0, value=1.0, step=0.01, label="Top-p")
|
242 |
repetition_penalty = gr.Slider(minimum=1.0, maximum=2.0, value=1.0, step=0.01, label="Repetition Penalty")
|
|
|
79 |
|
80 |
joinus = """🌟TeamTonic🌟 is always making cool demos! Join our active builder's 🛠️community 👻 [](https://discord.gg/qdfnvSPcqP) On 🤗Huggingface:[MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to🌟 [Build Tonic](https://git.tonic-ai.com/contribute)🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
|
81 |
"""
|
82 |
+
howto = """The advanced settings allow you to fine-tune the text generation process. Here's what each setting does and how to use it:
|
83 |
|
84 |
+
### Top-k (Default: 50)
|
85 |
+
Top-k sampling limits the next token selection to the k most likely tokens.
|
86 |
+
|
87 |
+
- **Lower values** (e.g., 10) make the output more focused and deterministic.
|
88 |
+
- **Higher values** (e.g., 100) allow for more diverse outputs.
|
89 |
+
|
90 |
+
**Example:** For a creative writing task, try setting top-k to 80 for more varied language.
|
91 |
+
|
92 |
+
### Top-p (Default: 1.0)
|
93 |
+
Top-p (or nucleus) sampling selects from the smallest set of tokens whose cumulative probability exceeds p.
|
94 |
+
|
95 |
+
- **Lower values** (e.g., 0.5) make the output more focused and coherent.
|
96 |
+
- **Higher values** (e.g., 0.9) allow for more diverse and potentially creative outputs.
|
97 |
+
|
98 |
+
**Example:** For a factual caption, set top-p to 0.7 to balance accuracy and creativity.
|
99 |
+
|
100 |
+
### Repetition Penalty (Default: 1.0)
|
101 |
+
This penalizes repetition in the generated text.
|
102 |
+
|
103 |
+
- **Values closer to 1.0** have minimal effect on repetition.
|
104 |
+
- **Higher values** (e.g., 1.5) more strongly discourage repetition.
|
105 |
+
|
106 |
+
**Example:** If you notice repeated phrases, try increasing to 1.2 for more varied text.
|
107 |
+
|
108 |
+
### Number of Beams (Default: 3)
|
109 |
+
Beam search explores multiple possible sequences in parallel.
|
110 |
+
|
111 |
+
- **Higher values** (e.g., 5) can lead to better quality but slower generation.
|
112 |
+
- **Lower values** (e.g., 1) are faster but may produce lower quality results.
|
113 |
+
|
114 |
+
**Example:** For complex tasks like dense captioning, try increasing to 5 beams.
|
115 |
+
|
116 |
+
### Max Tokens (Default: 512)
|
117 |
+
This sets the maximum length of the generated text.
|
118 |
+
|
119 |
+
- **Lower values** (e.g., 100) for concise outputs.
|
120 |
+
- **Higher values** (e.g., 1000) for more detailed descriptions.
|
121 |
+
|
122 |
+
**Example:** For a detailed image description, set max tokens to 800 for a comprehensive output.
|
123 |
+
|
124 |
+
Remember, these settings interact with each other, so experimenting with different combinations can lead to interesting results!
|
125 |
+
"""
|
126 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
127 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
128 |
|
|
|
174 |
plt.text(x1, y1, label, color='white', fontsize=8, bbox=dict(facecolor='red', alpha=0.5))
|
175 |
|
176 |
ax.axis('off')
|
177 |
+
|
178 |
return fig
|
179 |
|
180 |
def draw_ocr_bboxes(image, prediction):
|
|
|
270 |
with gr.Group():
|
271 |
gr.Markdown(description)
|
272 |
with gr.Row():
|
273 |
+
with gr.Accordion("🫱🏻🫲🏻Join Us", open=True):
|
274 |
gr.Markdown(joinus)
|
275 |
with gr.Row():
|
276 |
with gr.Column(scale=1):
|
|
|
280 |
submit_button = gr.Button("📸📈✍🏻Process")
|
281 |
reset_button = gr.Button("♻️Reset")
|
282 |
with gr.Accordion("🧪Advanced Settings", open=False):
|
283 |
+
with gr.Accordion("🏗️How To Use", open=True):
|
284 |
+
gr.Markdown(how_to_use)
|
285 |
top_k = gr.Slider(minimum=1, maximum=100, value=50, step=1, label="Top-k")
|
286 |
top_p = gr.Slider(minimum=0.0, maximum=1.0, value=1.0, step=0.01, label="Top-p")
|
287 |
repetition_penalty = gr.Slider(minimum=1.0, maximum=2.0, value=1.0, step=0.01, label="Repetition Penalty")
|