Spaces:
Running
Running
Improve formatting of plot
Browse files- gui/Dockerfile +7 -0
- gui/app.py +36 -0
gui/Dockerfile
CHANGED
|
@@ -11,10 +11,17 @@ RUN apt-get update && \
|
|
| 11 |
libgl1-mesa-glx \
|
| 12 |
libglib2.0-0 \
|
| 13 |
libpython3-dev \
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
&& \
|
| 15 |
apt-get clean && \
|
| 16 |
rm -rf /var/lib/apt/lists/*
|
| 17 |
|
|
|
|
|
|
|
|
|
|
| 18 |
WORKDIR /code
|
| 19 |
|
| 20 |
COPY ./requirements.txt /code/requirements.txt
|
|
|
|
| 11 |
libgl1-mesa-glx \
|
| 12 |
libglib2.0-0 \
|
| 13 |
libpython3-dev \
|
| 14 |
+
libfreetype6-dev \
|
| 15 |
+
pkg-config \
|
| 16 |
+
libfontconfig1 \
|
| 17 |
+
fontconfig \
|
| 18 |
&& \
|
| 19 |
apt-get clean && \
|
| 20 |
rm -rf /var/lib/apt/lists/*
|
| 21 |
|
| 22 |
+
COPY fonts/*.ttf /usr/local/share/fonts/
|
| 23 |
+
RUN fc-cache -f -v
|
| 24 |
+
|
| 25 |
WORKDIR /code
|
| 26 |
|
| 27 |
COPY ./requirements.txt /code/requirements.txt
|
gui/app.py
CHANGED
|
@@ -268,6 +268,8 @@ def main():
|
|
| 268 |
blocks["df"] = gr.Dataframe(
|
| 269 |
headers=["complexity", "loss", "equation"],
|
| 270 |
datatype=["number", "number", "str"],
|
|
|
|
|
|
|
| 271 |
)
|
| 272 |
blocks["run"] = gr.Button()
|
| 273 |
|
|
@@ -339,5 +341,39 @@ def replot_pareto(df, maxsize):
|
|
| 339 |
|
| 340 |
return fig
|
| 341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
if __name__ == "__main__":
|
| 343 |
main()
|
|
|
|
| 268 |
blocks["df"] = gr.Dataframe(
|
| 269 |
headers=["complexity", "loss", "equation"],
|
| 270 |
datatype=["number", "number", "str"],
|
| 271 |
+
wrap=True,
|
| 272 |
+
column_widths=[100, 100, 300],
|
| 273 |
)
|
| 274 |
blocks["run"] = gr.Button()
|
| 275 |
|
|
|
|
| 341 |
|
| 342 |
return fig
|
| 343 |
|
| 344 |
+
def replot_pareto(df, maxsize):
|
| 345 |
+
plt.rcParams['font.family'] = 'IBM Plex Mono'
|
| 346 |
+
fig, ax = plt.subplots(figsize=(6, 6), dpi=100)
|
| 347 |
+
|
| 348 |
+
if len(df) == 0 or 'Equation' not in df.columns:
|
| 349 |
+
return fig
|
| 350 |
+
|
| 351 |
+
# Plotting the data
|
| 352 |
+
ax.loglog(df['Complexity'], df['Loss'], marker='o', linestyle='-', color='#333f48', linewidth=1.5, markersize=6)
|
| 353 |
+
|
| 354 |
+
# Set the axis limits
|
| 355 |
+
ax.set_xlim(0.5, maxsize + 1)
|
| 356 |
+
ytop = 2 ** (np.ceil(np.log2(df['Loss'].max())))
|
| 357 |
+
ybottom = 2 ** (np.floor(np.log2(df['Loss'].min() + 1e-20)))
|
| 358 |
+
ax.set_ylim(ybottom, ytop)
|
| 359 |
+
|
| 360 |
+
ax.grid(True, which="both", ls="--", linewidth=0.5, color='gray', alpha=0.5)
|
| 361 |
+
ax.spines['top'].set_visible(False)
|
| 362 |
+
ax.spines['right'].set_visible(False)
|
| 363 |
+
|
| 364 |
+
# Range-frame the plot
|
| 365 |
+
for direction in ['bottom', 'left']:
|
| 366 |
+
ax.spines[direction].set_position(('outward', 10))
|
| 367 |
+
|
| 368 |
+
# Delete far ticks
|
| 369 |
+
ax.tick_params(axis='both', which='major', labelsize=10, direction='out', length=5)
|
| 370 |
+
ax.tick_params(axis='both', which='minor', labelsize=8, direction='out', length=3)
|
| 371 |
+
|
| 372 |
+
ax.set_xlabel('Complexity')
|
| 373 |
+
ax.set_ylabel('Loss')
|
| 374 |
+
fig.tight_layout(pad=2)
|
| 375 |
+
|
| 376 |
+
return fig
|
| 377 |
+
|
| 378 |
if __name__ == "__main__":
|
| 379 |
main()
|