Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,8 @@ import networkx as nx
|
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
import pandas as pd
|
| 6 |
from sklearn.metrics import log_loss
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def sigmoid(z):
|
| 9 |
return 1.0/(1.0+ np.exp(-z))
|
|
@@ -77,10 +79,13 @@ def visualize_neural(a):
|
|
| 77 |
labels = nx.get_edge_attributes(G, 'weight')
|
| 78 |
nx.draw_networkx_edge_labels(G, pos, edge_labels=labels,font_size=3,label_pos=0.8)
|
| 79 |
plt.title('Neural Network Graph')
|
| 80 |
-
|
| 81 |
-
plt.
|
| 82 |
buffer.seek(0)
|
| 83 |
image = Image.open(buffer)
|
|
|
|
|
|
|
|
|
|
| 84 |
image_array = np.array(image)
|
| 85 |
if output<0.5:
|
| 86 |
return image_array,"Non palindrom"
|
|
|
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
import pandas as pd
|
| 6 |
from sklearn.metrics import log_loss
|
| 7 |
+
from io import BytesIO
|
| 8 |
+
from PIL import Image
|
| 9 |
|
| 10 |
def sigmoid(z):
|
| 11 |
return 1.0/(1.0+ np.exp(-z))
|
|
|
|
| 79 |
labels = nx.get_edge_attributes(G, 'weight')
|
| 80 |
nx.draw_networkx_edge_labels(G, pos, edge_labels=labels,font_size=3,label_pos=0.8)
|
| 81 |
plt.title('Neural Network Graph')
|
| 82 |
+
buffer = BytesIO()
|
| 83 |
+
plt.savefig(buffer, format='png') # Save the plot to the buffer in PNG format
|
| 84 |
buffer.seek(0)
|
| 85 |
image = Image.open(buffer)
|
| 86 |
+
plt.close() # Close the plot to prevent displaying it
|
| 87 |
+
|
| 88 |
+
# Convert the PIL image to a numpy array
|
| 89 |
image_array = np.array(image)
|
| 90 |
if output<0.5:
|
| 91 |
return image_array,"Non palindrom"
|