Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,10 @@ from paddleocr import PaddleOCR, draw_ocr
|
|
10 |
from PIL import Image
|
11 |
import torch
|
12 |
import re
|
|
|
|
|
|
|
|
|
13 |
|
14 |
w_style="""
|
15 |
<style>
|
@@ -76,6 +80,21 @@ def fx8(x,y,z):
|
|
76 |
res=re.sub(r'{0}'.format(x),y,z)
|
77 |
return res
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
with demo:
|
80 |
gr.Markdown(
|
81 |
"""
|
@@ -120,7 +139,13 @@ with demo:
|
|
120 |
zz2_input = [gr.Textbox(placeholder='输入正则表达式,如"\d+"',label="输入正则表达式"),gr.Textbox(placeholder='正则匹配对象替换为啥',label="输入替换为的字符串"),gr.Textbox(placeholder='待替换对象',label="输入原始字符串")]
|
121 |
zz2_output = gr.Textbox(label="输出",show_label=True)
|
122 |
zz2_button = gr.Button("开始正则替换>>")
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
tj_button.click(fx1, inputs=text_input, outputs=text_output)
|
125 |
cs_button.click(fx2, inputs=val_input, outputs=json_output,api_name="ghqj")
|
126 |
dq_button.click(fx3, inputs=file_input, outputs=table_output,api_name="df")
|
@@ -129,5 +154,6 @@ with demo:
|
|
129 |
ocr_button.click(fx6,inputs=ocr_input,outputs=ocr_output,api_name="ocr")
|
130 |
zz1_button.click(fx7,inputs=zz1_input,outputs=zz1_output,api_name="zzpp")
|
131 |
zz2_button.click(fx8,inputs=zz2_input,outputs=zz2_output,api_name="zzth")
|
|
|
132 |
|
133 |
demo.launch(enable_queue=True)
|
|
|
10 |
from PIL import Image
|
11 |
import torch
|
12 |
import re
|
13 |
+
import matplotlib
|
14 |
+
matplotlib.use('Agg')
|
15 |
+
import matplotlib.pyplot as plt
|
16 |
+
import numpy as np
|
17 |
|
18 |
w_style="""
|
19 |
<style>
|
|
|
80 |
res=re.sub(r'{0}'.format(x),y,z)
|
81 |
return res
|
82 |
|
83 |
+
def plot(v, a):
|
84 |
+
g = 9.81
|
85 |
+
theta = a / 180 * 3.14
|
86 |
+
tmax = ((2 * v) * np.sin(theta)) / g
|
87 |
+
timemat = tmax * np.linspace(0, 1, 40)[:, None]
|
88 |
+
|
89 |
+
x = (v * timemat) * np.cos(theta)
|
90 |
+
y = ((v * timemat) * np.sin(theta)) - ((0.5 * g) * (timemat**2))
|
91 |
+
|
92 |
+
fig = plt.figure()
|
93 |
+
plt.scatter(x=x, y=y, marker=".")
|
94 |
+
plt.xlim(0, 100)
|
95 |
+
plt.ylim(0, 60)
|
96 |
+
return fig
|
97 |
+
|
98 |
with demo:
|
99 |
gr.Markdown(
|
100 |
"""
|
|
|
139 |
zz2_input = [gr.Textbox(placeholder='输入正则表达式,如"\d+"',label="输入正则表达式"),gr.Textbox(placeholder='正则匹配对象替换为啥',label="输入替换为的字符串"),gr.Textbox(placeholder='待替换对象',label="输入原始字符串")]
|
140 |
zz2_output = gr.Textbox(label="输出",show_label=True)
|
141 |
zz2_button = gr.Button("开始正则替换>>")
|
142 |
+
with gr.TabItem("图表展示"):
|
143 |
+
with gr.Group()
|
144 |
+
speed = gr.Slider(1, 30, 25, label="Speed")
|
145 |
+
angle = gr.Slider(0, 90, 45, label="Angle")
|
146 |
+
output = gr.Plot()
|
147 |
+
tb_button = gr.Button("Run")
|
148 |
+
|
149 |
tj_button.click(fx1, inputs=text_input, outputs=text_output)
|
150 |
cs_button.click(fx2, inputs=val_input, outputs=json_output,api_name="ghqj")
|
151 |
dq_button.click(fx3, inputs=file_input, outputs=table_output,api_name="df")
|
|
|
154 |
ocr_button.click(fx6,inputs=ocr_input,outputs=ocr_output,api_name="ocr")
|
155 |
zz1_button.click(fx7,inputs=zz1_input,outputs=zz1_output,api_name="zzpp")
|
156 |
zz2_button.click(fx8,inputs=zz2_input,outputs=zz2_output,api_name="zzth")
|
157 |
+
tb_button.click(plot, [speed, angle], output)
|
158 |
|
159 |
demo.launch(enable_queue=True)
|