3morrrrr commited on
Commit
b1667f5
·
verified ·
1 Parent(s): 260f21a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -36,13 +36,18 @@ def generate_handwriting(
36
  biases = [bias] * len(lines)
37
  styles = [style] * len(lines)
38
 
39
- # Input validation
 
40
  for line_num, line in enumerate(lines):
41
  if len(line) > 75:
42
  return f"Error: Line {line_num+1} is too long (max 75 characters)"
 
 
 
 
43
 
44
  data = InputData(
45
- text=text,
46
  style=style,
47
  bias=bias,
48
  stroke_colors=stroke_colors,
@@ -54,10 +59,10 @@ def generate_handwriting(
54
  except ValueError as e:
55
  return f"Error: {str(e)}"
56
 
57
- # Generate the handwriting
58
  hand.write(
59
  filename='img/output.svg',
60
- lines=lines,
61
  biases=biases,
62
  styles=styles,
63
  stroke_colors=stroke_colors,
@@ -116,7 +121,7 @@ css = """
116
 
117
  with gr.Blocks(css=css) as demo:
118
  gr.Markdown("# 🖋️ Handwriting Synthesis")
119
- gr.Markdown("Generate realistic handwritten text using neural networks")
120
 
121
  with gr.Row():
122
  with gr.Column(scale=2):
@@ -179,11 +184,12 @@ with gr.Blocks(css=css) as demo:
179
  - Adjust the neatness slider to make writing more or less tidy
180
  - Each line should be 75 characters or less
181
  - The model works best for English text
 
182
  """)
183
 
184
  gr.Markdown("""
185
  <div class="footer">
186
- Created with Gradio •>
187
  </div>
188
  """)
189
 
 
36
  biases = [bias] * len(lines)
37
  styles = [style] * len(lines)
38
 
39
+ # Process each line to replace slashes with dashes
40
+ sanitized_lines = []
41
  for line_num, line in enumerate(lines):
42
  if len(line) > 75:
43
  return f"Error: Line {line_num+1} is too long (max 75 characters)"
44
+
45
+ # Replace slashes with dashes
46
+ sanitized_line = line.replace('/', '-').replace('\\', '-')
47
+ sanitized_lines.append(sanitized_line)
48
 
49
  data = InputData(
50
+ text='\n'.join(sanitized_lines),
51
  style=style,
52
  bias=bias,
53
  stroke_colors=stroke_colors,
 
59
  except ValueError as e:
60
  return f"Error: {str(e)}"
61
 
62
+ # Generate the handwriting with sanitized lines
63
  hand.write(
64
  filename='img/output.svg',
65
+ lines=sanitized_lines,
66
  biases=biases,
67
  styles=styles,
68
  stroke_colors=stroke_colors,
 
121
 
122
  with gr.Blocks(css=css) as demo:
123
  gr.Markdown("# 🖋️ Handwriting Synthesis")
124
+ gr.Markdown("Generate realistic handwritten text using neural networks.")
125
 
126
  with gr.Row():
127
  with gr.Column(scale=2):
 
184
  - Adjust the neatness slider to make writing more or less tidy
185
  - Each line should be 75 characters or less
186
  - The model works best for English text
187
+ - Forward slashes (/) and backslashes (\\) will be replaced with dashes (-)
188
  """)
189
 
190
  gr.Markdown("""
191
  <div class="footer">
192
+ Created with Gradio
193
  </div>
194
  """)
195