gitshiva commited on
Commit
4fd9a43
Β·
1 Parent(s): 6cc48cc

initial commit, working fine

Browse files
Files changed (3) hide show
  1. app.py +20 -0
  2. samplemodel01.ipynb +150 -0
  3. samplemodel01.keras +0 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ from tensorflow import keras
3
+ import gradio as gr
4
+
5
+ model = tf.keras.models.load_model('samplemodel01.keras')
6
+
7
+ def prediction(x):
8
+ a2 = [[int(x)]]
9
+ # print (a2)
10
+ a2 = tf.convert_to_tensor(a2)
11
+ return model.predict(a2)
12
+
13
+
14
+ demo = gr.Interface(
15
+ fn=prediction,
16
+ inputs=["text"],
17
+ outputs=["text"]
18
+ )
19
+
20
+ demo.launch(server_name="0.0.0.0", share=True)
samplemodel01.ipynb ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 3,
6
+ "id": "55639ddf-442f-4da9-be1d-75543a2e0c70",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "name": "stderr",
11
+ "output_type": "stream",
12
+ "text": [
13
+ "2024-03-12 20:49:33.250521: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.\n",
14
+ "2024-03-12 20:49:33.298077: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
15
+ "2024-03-12 20:49:33.298108: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
16
+ "2024-03-12 20:49:33.299348: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n",
17
+ "2024-03-12 20:49:33.307159: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n",
18
+ "To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
19
+ "2024-03-12 20:49:34.869437: I itex/core/wrapper/itex_cpu_wrapper.cc:60] Intel Extension for Tensorflow* AVX512 CPU backend is loaded.\n",
20
+ "2024-03-12 20:49:34.962813: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
21
+ "2024-03-12 20:49:34.993825: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
22
+ "2024-03-12 20:49:34.997527: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n"
23
+ ]
24
+ }
25
+ ],
26
+ "source": [
27
+ "import tensorflow as tf\n",
28
+ "from tensorflow import keras"
29
+ ]
30
+ },
31
+ {
32
+ "cell_type": "code",
33
+ "execution_count": 7,
34
+ "id": "f0852765-7e18-41df-aecf-10bbc9649010",
35
+ "metadata": {},
36
+ "outputs": [],
37
+ "source": [
38
+ "model = tf.keras.models.load_model('samplemodel01.keras')"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type": "code",
43
+ "execution_count": 8,
44
+ "id": "a958a761-107d-4dbd-8055-ba4085b80de6",
45
+ "metadata": {},
46
+ "outputs": [],
47
+ "source": [
48
+ "y_pred = tf.convert_to_tensor([[11000]])"
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "code",
53
+ "execution_count": 9,
54
+ "id": "4aa44234-0cfc-4e3b-9b44-e741f6521a0c",
55
+ "metadata": {},
56
+ "outputs": [
57
+ {
58
+ "name": "stderr",
59
+ "output_type": "stream",
60
+ "text": [
61
+ "2024-03-12 20:52:50.931243: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:117] Plugin optimizer for device_type CPU is enabled.\n",
62
+ "2024-03-12 20:52:51.026576: I external/local_xla/xla/service/service.cc:168] XLA service 0x55d7aadc8c40 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:\n",
63
+ "2024-03-12 20:52:51.026653: I external/local_xla/xla/service/service.cc:176] StreamExecutor device (0): Quadro RTX 4000, Compute Capability 7.5\n",
64
+ "2024-03-12 20:52:51.041029: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:269] disabling MLIR crash reproducer, set env var `MLIR_CRASH_REPRODUCER_DIRECTORY` to enable.\n",
65
+ "2024-03-12 20:52:51.101126: I external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:454] Loaded cuDNN version 8907\n",
66
+ "2024-03-12 20:52:51.104547: I external/local_tsl/tsl/platform/default/subprocess.cc:304] Start cannot spawn child process: No such file or directory\n"
67
+ ]
68
+ },
69
+ {
70
+ "name": "stdout",
71
+ "output_type": "stream",
72
+ "text": [
73
+ "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 303ms/step\n"
74
+ ]
75
+ },
76
+ {
77
+ "name": "stderr",
78
+ "output_type": "stream",
79
+ "text": [
80
+ "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
81
+ "I0000 00:00:1710276771.219566 85038 device_compiler.h:186] Compiled cluster using XLA! This line is logged at most once for the lifetime of the process.\n"
82
+ ]
83
+ }
84
+ ],
85
+ "source": [
86
+ "pred = model.predict(y_pred)"
87
+ ]
88
+ },
89
+ {
90
+ "cell_type": "code",
91
+ "execution_count": 10,
92
+ "id": "214f3a54-95f4-4c5e-b211-608e62d26cc2",
93
+ "metadata": {},
94
+ "outputs": [
95
+ {
96
+ "data": {
97
+ "text/plain": [
98
+ "array([[22005.293]], dtype=float32)"
99
+ ]
100
+ },
101
+ "execution_count": 10,
102
+ "metadata": {},
103
+ "output_type": "execute_result"
104
+ }
105
+ ],
106
+ "source": [
107
+ "pred"
108
+ ]
109
+ },
110
+ {
111
+ "cell_type": "code",
112
+ "execution_count": 12,
113
+ "id": "8b719dcf-155d-40d1-a111-56181030968d",
114
+ "metadata": {},
115
+ "outputs": [
116
+ {
117
+ "name": "stdout",
118
+ "output_type": "stream",
119
+ "text": [
120
+ "[22005.293]\n"
121
+ ]
122
+ }
123
+ ],
124
+ "source": [
125
+ "print (str(pred[0]))"
126
+ ]
127
+ }
128
+ ],
129
+ "metadata": {
130
+ "kernelspec": {
131
+ "display_name": "Python 3 (ipykernel)",
132
+ "language": "python",
133
+ "name": "python3"
134
+ },
135
+ "language_info": {
136
+ "codemirror_mode": {
137
+ "name": "ipython",
138
+ "version": 3
139
+ },
140
+ "file_extension": ".py",
141
+ "mimetype": "text/x-python",
142
+ "name": "python",
143
+ "nbconvert_exporter": "python",
144
+ "pygments_lexer": "ipython3",
145
+ "version": "3.10.12"
146
+ }
147
+ },
148
+ "nbformat": 4,
149
+ "nbformat_minor": 5
150
+ }
samplemodel01.keras ADDED
Binary file (75.7 kB). View file