Skip to content

Instantly share code, notes, and snippets.

@huseinzol05
Created June 22, 2022 04:09
Show Gist options
  • Save huseinzol05/ff7f1aa68633a45e4ae69d4d3a2576af to your computer and use it in GitHub Desktop.
Save huseinzol05/ff7f1aa68633a45e4ae69d4d3a2576af to your computer and use it in GitHub Desktop.
Sync from B2 to HuggingFace
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"id": "0e472f4f",
"metadata": {},
"outputs": [],
"source": [
"from malaya_boilerplate.huggingface import upload_dict"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "55b2a4ed",
"metadata": {},
"outputs": [],
"source": [
"# !rclone sync b2:malaya-speech-model/noise-reduction ."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "e9647178",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['unet/model.pb',\n",
" 'resnext-unet/model.pb',\n",
" 'resnet-unet/model.pb',\n",
" 'resnext/model.pb',\n",
" 'resnext-unet-quantized/model.pb',\n",
" 'resnext-quantized/model.pb',\n",
" 'resnet-unet-quantized/model.pb',\n",
" 'unet-quantized/model.pb']"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from glob import glob\n",
"import os\n",
"\n",
"pbs = glob('*/*.pb')\n",
"pbs"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "b0b2c951",
"metadata": {},
"outputs": [],
"source": [
"module = 'noise-reduction'"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "a7c16e11",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"unet/model.pb\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"409 Client Error: Conflict for url: https://huggingface.co/api/repos/create - You already created this model repo\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"resnext-unet/model.pb\n",
"resnet-unet/model.pb\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"409 Client Error: Conflict for url: https://huggingface.co/api/repos/create - You already created this model repo\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"resnext/model.pb\n",
"resnext-unet-quantized/model.pb\n",
"resnext-quantized/model.pb\n",
"resnet-unet-quantized/model.pb\n",
"unet-quantized/model.pb\n"
]
}
],
"source": [
"for file in pbs:\n",
" print(file)\n",
" d, f = os.path.split(file)\n",
" upload_dict(f'{module}-{d}', {file: f})"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "41436765",
"metadata": {},
"outputs": [],
"source": [
"os.environ['CUDA_VISIBLE_DEVICES'] = ''"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "c767d1f5",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/ubuntu/.local/lib/python3.8/site-packages/tensorflow_addons/utils/ensure_tf_install.py:53: UserWarning: Tensorflow Addons supports using Python ops for all Tensorflow versions above or equal to 2.3.0 and strictly below 2.5.0 (nightly versions are not supported). \n",
" The versions of TensorFlow you are currently using is 2.6.0 and is not supported. \n",
"Some things might work, some things might not.\n",
"If you were to encounter a bug, do not file an issue.\n",
"If you want to make sure you're using a tested and supported configuration, either change the TensorFlow version or the TensorFlow Addons's version. \n",
"You can find the compatibility matrix in TensorFlow Addon's readme:\n",
"https://github.com/tensorflow/addons\n",
" warnings.warn(\n",
"/home/ubuntu/.local/lib/python3.8/site-packages/tensorflow_addons/utils/resource_loader.py:72: UserWarning: You are currently using TensorFlow 2.6.0 and trying to load a custom op (custom_ops/seq2seq/_beam_search_ops.so).\n",
"TensorFlow Addons has compiled its custom ops against TensorFlow 2.4.0, and there are no compatibility guarantees between the two versions. \n",
"This means that you might get segfaults when loading the custom op, or other kind of low-level errors.\n",
" If you do, do not file an issue on Github. This is a known limitation.\n",
"\n",
"It might help you to fallback to pure Python ops with TF_ADDONS_PY_OPS . To do that, see https://github.com/tensorflow/addons#gpucpu-custom-ops \n",
"\n",
"You can also change the TensorFlow version installed on your system. You would need a TensorFlow version equal to or above 2.4.0 and strictly below 2.5.0.\n",
" Note that nightly versions of TensorFlow, as well as non-pip TensorFlow like `conda install tensorflow` or compiled from source are not supported.\n",
"\n",
"The last solution is to find the TensorFlow Addons version that has custom ops compatible with the TensorFlow installed on your system. To do that, refer to the readme: https://github.com/tensorflow/addons\n",
" warnings.warn(\n",
"/home/ubuntu/.local/lib/python3.8/site-packages/malaya_boilerplate/frozen_graph.py:28: UserWarning: Cannot import beam_search_ops from Tensorflow Addons, `deep_model` for stemmer will not available to use, make sure Tensorflow Addons version >= 0.12.0\n",
" warnings.warn(\n"
]
}
],
"source": [
"import malaya_speech"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "70e05457",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fcc327f642784ccfa53e24977dfdaaf9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading: 0%| | 0.00/96.7M [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-06-22 12:04:48.934093: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 AVX512F FMA\n",
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
"2022-06-22 12:04:48.939930: E tensorflow/stream_executor/cuda/cuda_driver.cc:271] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected\n",
"2022-06-22 12:04:48.939949: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: huseincomel-desktop\n",
"2022-06-22 12:04:48.939954: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: huseincomel-desktop\n",
"2022-06-22 12:04:48.940014: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:200] libcuda reported version is: Not found: was unable to find libcuda.so DSO loaded into this program\n",
"2022-06-22 12:04:48.940038: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:204] kernel reported version is: 470.129.6\n"
]
},
{
"data": {
"text/plain": [
"<malaya_speech.model.unet.UNETSTFT at 0x7fbf885e6130>"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"malaya_speech.noise_reduction.deep_model(model = 'resnet-unet')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "52b1c988",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment