Rooni commited on
Commit
af3af65
·
verified ·
1 Parent(s): 2069a78

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -107,8 +107,23 @@ css = """
107
  footer {visibility: hidden !important;}
108
  """
109
 
110
- # Создаем интерфейс с помощью Gradio
111
- with gr.Blocks(css=css, theme='YTheme/SmartLearn') as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  with gr.Row():
113
  with gr.Column():
114
  image_input = gr.Image(label="Фото", type="pil")
@@ -126,20 +141,5 @@ with gr.Blocks(css=css, theme='YTheme/SmartLearn') as demo:
126
  concurrency_limit=200
127
  )
128
 
129
- # Добавляем JavaScript для обработки ввода символов в текстовое поле
130
- demo.add_js("""
131
- document.addEventListener('DOMContentLoaded', function() {
132
- const instructionElement = document.querySelector('textarea');
133
- const charCounterElement = document.querySelector('label[for="textbox"]');
134
-
135
- function updateCharCount() {
136
- const text = instructionElement.value.replace(/\\s+/g, '');
137
- const charCount = text.length;
138
- charCounterElement.textContent = `${charCount}/250`;
139
- }
140
-
141
- instructionElement.addEventListener('input', updateCharCount);
142
- });
143
- """)
144
-
145
  demo.launch()
 
107
  footer {visibility: hidden !important;}
108
  """
109
 
110
+ custom_javascript = """
111
+ document.addEventListener('DOMContentLoaded', function() {
112
+ const instructionElement = document.querySelector('textarea');
113
+ const charCounterElement = document.querySelector('label[for="textbox"]');
114
+
115
+ function updateCharCount() {
116
+ const text = instructionElement.value.replace(/\\s+/g, '');
117
+ const charCount = text.length;
118
+ charCounterElement.textContent = `${charCount}/250`;
119
+ }
120
+
121
+ instructionElement.addEventListener('input', updateCharCount);
122
+ });
123
+ """
124
+
125
+ # Создаем интерфейс с помощью Gradio, используя аргумент javascript
126
+ with gr.Blocks(css=css, theme='YTheme/SmartLearn', javascript=custom_javascript) as demo:
127
  with gr.Row():
128
  with gr.Column():
129
  image_input = gr.Image(label="Фото", type="pil")
 
141
  concurrency_limit=200
142
  )
143
 
144
+ # Запускаем интерфейс
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  demo.launch()