Spaces:
Runtime error
Runtime error
Joshua Lansford
commited on
Commit
·
a362d69
1
Parent(s):
b90eb25
The app should be working.
Browse files- app.py +55 -0
- phonetics_gpu_4000.tm → examples/phonetic/phonetics_gpu_4000.tm +0 -0
- reverse_phonetics_gpu_4000.tm → examples/phonetic/reverse_phonetics_gpu_4000.tm +0 -0
- piglattin_gpu_4000.tm → examples/piglattin/piglattin_gpu_4000.tm +0 -0
- reverse_piglattin_gpu_4000.tm → examples/piglattin/reverse_piglattin_gpu_4000.tm +0 -0
- phonetics_backwards.tm +0 -3
- phonetics_forward.tm +0 -3
- run_tests.sh +65 -29
- run_tests2.sh +46 -0
- transmorgrify.py +2 -0
app.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import transmorgrify
|
| 3 |
+
|
| 4 |
+
eng_to_ipa_tm = transmorgrify.Transmorgrifyer()
|
| 5 |
+
eng_to_ipa_tm.load( "./examples/phonetic/phonetics_gpu_4000.tm" )
|
| 6 |
+
|
| 7 |
+
ipa_to_eng_tm = transmorgrify.Transmorgrifyer()
|
| 8 |
+
ipa_to_eng_tm.load( "./examples/phonetic/reverse_phonetics_gpu_4000.tm")
|
| 9 |
+
|
| 10 |
+
eng_to_pig_tm = transmorgrify.Transmorgrifyer()
|
| 11 |
+
eng_to_pig_tm.load( "./examples/piglattin/piglattin_gpu_4000.tm" )
|
| 12 |
+
|
| 13 |
+
pig_to_eng_tm = transmorgrify.Transmorgrifyer()
|
| 14 |
+
pig_to_eng_tm.load( "./examples/piglattin/reverse_piglattin_gpu_4000.tm" )
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def eng_to_ipa( input ):
|
| 18 |
+
return list(eng_to_ipa_tm.execute( [input] ) )[0]
|
| 19 |
+
|
| 20 |
+
def ipa_to_eng( input ):
|
| 21 |
+
return list(ipa_to_eng_tm.execute( [input] ) )[0]
|
| 22 |
+
|
| 23 |
+
def eng_to_pig( input ):
|
| 24 |
+
return list(eng_to_pig_tm.execute( [input] ) )[0]
|
| 25 |
+
|
| 26 |
+
def pig_to_eng( input ):
|
| 27 |
+
return list(pig_to_eng_tm.execute( [input] ) )[0]
|
| 28 |
+
|
| 29 |
+
with gr.Blocks() as demo:
|
| 30 |
+
gr.Markdown(
|
| 31 |
+
"""
|
| 32 |
+
# Sentance Transmorgrifier demo
|
| 33 |
+
The following demos have been trained on different tasks.
|
| 34 |
+
Select the tab below for a demo.
|
| 35 |
+
"""
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
with gr.Tab( "IPA" ):
|
| 39 |
+
english_in = gr.Textbox( label="English in" )
|
| 40 |
+
ipa_out = gr.Textbox( label='IPA out')
|
| 41 |
+
gr.Button( value='Transmorgrify' ).click( eng_to_ipa, english_in, ipa_out )
|
| 42 |
+
|
| 43 |
+
ipa_in = gr.Textbox( label="IPA in" )
|
| 44 |
+
english_out = gr.Textbox( label='English out')
|
| 45 |
+
gr.Button( value='Transmorgrify' ).click( ipa_to_eng , ipa_in, english_out )
|
| 46 |
+
|
| 47 |
+
with gr.Tab( "Piglattin" ):
|
| 48 |
+
english_in = gr.Textbox( label="English in" )
|
| 49 |
+
pig_out = gr.Textbox( label='Pig latin out')
|
| 50 |
+
gr.Button( value='Transmorgrify' ).click( eng_to_pig, english_in, pig_out )
|
| 51 |
+
|
| 52 |
+
pig_in = gr.Textbox( label="Pig latin in" )
|
| 53 |
+
english_out = gr.Textbox( label='English out')
|
| 54 |
+
gr.Button( value='Transmorgrify' ).click( pig_to_eng , pig_in, english_out )
|
| 55 |
+
demo.launch()
|
phonetics_gpu_4000.tm → examples/phonetic/phonetics_gpu_4000.tm
RENAMED
|
File without changes
|
reverse_phonetics_gpu_4000.tm → examples/phonetic/reverse_phonetics_gpu_4000.tm
RENAMED
|
File without changes
|
piglattin_gpu_4000.tm → examples/piglattin/piglattin_gpu_4000.tm
RENAMED
|
File without changes
|
reverse_piglattin_gpu_4000.tm → examples/piglattin/reverse_piglattin_gpu_4000.tm
RENAMED
|
File without changes
|
phonetics_backwards.tm
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:ddc8d0418e4c8039a909aa104d9b8e5ce43444c7ee9a2878755a7d340d6b3771
|
| 3 |
-
size 14013630
|
|
|
|
|
|
|
|
|
|
|
|
phonetics_forward.tm
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:025957f43f95308bb4893b5407402ae619e88d6993481812ebc451726b14393a
|
| 3 |
-
size 8720186
|
|
|
|
|
|
|
|
|
|
|
|
run_tests.sh
CHANGED
|
@@ -1,56 +1,92 @@
|
|
| 1 |
!/usr/bin/env bash
|
| 2 |
-
echo test 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
./venv/bin/python transmorgrify.py \
|
| 4 |
-
--
|
| 5 |
-
--
|
| 6 |
-
--
|
| 7 |
-
--
|
| 8 |
-
--
|
|
|
|
| 9 |
--verbose \
|
| 10 |
-
--
|
|
|
|
| 11 |
--train_percentage 50
|
| 12 |
-
echo test
|
| 13 |
./venv/bin/python transmorgrify.py \
|
| 14 |
-
--
|
|
|
|
| 15 |
--a_header English \
|
| 16 |
--b_header Phonetic\
|
| 17 |
--device cpu \
|
| 18 |
-
--model
|
| 19 |
-
--verbose \
|
| 20 |
-
--iterations 2000 \
|
| 21 |
-
--train_percentage 50
|
| 22 |
-
echo test 3
|
| 23 |
-
./venv/bin/python transmorgrify.py \
|
| 24 |
-
--train --in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/phonetic/phonetic.csv \
|
| 25 |
-
--b_header English \
|
| 26 |
-
--a_header Phonetic\
|
| 27 |
-
--device cpu \
|
| 28 |
-
--model reverse_phonetics_cpu_2000.tm \
|
| 29 |
--verbose \
|
| 30 |
-
--
|
|
|
|
| 31 |
--train_percentage 50
|
|
|
|
|
|
|
| 32 |
echo test 4
|
| 33 |
./venv/bin/python transmorgrify.py \
|
| 34 |
--execute \
|
| 35 |
-
--in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/
|
| 36 |
-
--a_header
|
| 37 |
--b_header English \
|
| 38 |
--device cpu \
|
| 39 |
-
--model
|
| 40 |
--verbose \
|
| 41 |
--include_stats \
|
| 42 |
-
--out_csv ./
|
| 43 |
--train_percentage 50
|
| 44 |
echo test 5
|
| 45 |
./venv/bin/python transmorgrify.py \
|
| 46 |
--execute \
|
| 47 |
-
--in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/
|
| 48 |
--a_header English \
|
| 49 |
-
--b_header
|
| 50 |
--device cpu \
|
| 51 |
-
--model
|
| 52 |
--verbose \
|
| 53 |
--include_stats \
|
| 54 |
-
--out_csv ./
|
| 55 |
--train_percentage 50
|
| 56 |
|
|
|
|
| 1 |
!/usr/bin/env bash
|
| 2 |
+
# echo test 1
|
| 3 |
+
# ./venv/bin/python transmorgrify.py \
|
| 4 |
+
# --train --in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/phonetic/phonetic.csv \
|
| 5 |
+
# --a_header English \
|
| 6 |
+
# --b_header Phonetic\
|
| 7 |
+
# --device 0:1 \
|
| 8 |
+
# --model phonetics_gpu_4000.tm \
|
| 9 |
+
# --verbose \
|
| 10 |
+
# --iterations 4000 \
|
| 11 |
+
# --train_percentage 50
|
| 12 |
+
# echo test 2
|
| 13 |
+
# ./venv/bin/python transmorgrify.py \
|
| 14 |
+
# --train --in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/phonetic/phonetic.csv \
|
| 15 |
+
# --a_header English \
|
| 16 |
+
# --b_header Phonetic\
|
| 17 |
+
# --device cpu \
|
| 18 |
+
# --model phonetics_cpu_2000.tm \
|
| 19 |
+
# --verbose \
|
| 20 |
+
# --iterations 2000 \
|
| 21 |
+
# --train_percentage 50
|
| 22 |
+
# echo test 1b
|
| 23 |
+
# ./venv/bin/python transmorgrify.py \
|
| 24 |
+
# --train --in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/phonetic/phonetic.csv \
|
| 25 |
+
# --b_header English \
|
| 26 |
+
# --a_header Phonetic\
|
| 27 |
+
# --device 0:1 \
|
| 28 |
+
# --model reverse_phonetics_gpu_4000.tm \
|
| 29 |
+
# --verbose \
|
| 30 |
+
# --iterations 4000 \
|
| 31 |
+
# --train_percentage 50
|
| 32 |
+
# echo test 3
|
| 33 |
+
# ./venv/bin/python transmorgrify.py \
|
| 34 |
+
# --train --in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/phonetic/phonetic.csv \
|
| 35 |
+
# --b_header English \
|
| 36 |
+
# --a_header Phonetic\
|
| 37 |
+
# --device cpu \
|
| 38 |
+
# --model reverse_phonetics_cpu_2000.tm \
|
| 39 |
+
# --verbose \
|
| 40 |
+
# --iterations 2000 \
|
| 41 |
+
# --train_percentage 50
|
| 42 |
+
echo test 4
|
| 43 |
./venv/bin/python transmorgrify.py \
|
| 44 |
+
--execute \
|
| 45 |
+
--in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/phonetic/phonetic.csv \
|
| 46 |
+
--a_header Phonetic\
|
| 47 |
+
--b_header English \
|
| 48 |
+
--device cpu \
|
| 49 |
+
--model reverse_phonetics_gpu_4000.tm \
|
| 50 |
--verbose \
|
| 51 |
+
--include_stats \
|
| 52 |
+
--out_csv ./reverse_phonetics_out_gpu_4000.csv \
|
| 53 |
--train_percentage 50
|
| 54 |
+
echo test 5
|
| 55 |
./venv/bin/python transmorgrify.py \
|
| 56 |
+
--execute \
|
| 57 |
+
--in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/phonetic/phonetic.csv \
|
| 58 |
--a_header English \
|
| 59 |
--b_header Phonetic\
|
| 60 |
--device cpu \
|
| 61 |
+
--model phonetics_gpu_4000.tm \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
--verbose \
|
| 63 |
+
--include_stats \
|
| 64 |
+
--out_csv ./phonetics_out_gpu_4000.csv \
|
| 65 |
--train_percentage 50
|
| 66 |
+
|
| 67 |
+
|
| 68 |
echo test 4
|
| 69 |
./venv/bin/python transmorgrify.py \
|
| 70 |
--execute \
|
| 71 |
+
--in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/piglattin/pig_lattin.csv \
|
| 72 |
+
--a_header Piglattin\
|
| 73 |
--b_header English \
|
| 74 |
--device cpu \
|
| 75 |
+
--model reverse_piglattin_gpu_4000.tm \
|
| 76 |
--verbose \
|
| 77 |
--include_stats \
|
| 78 |
+
--out_csv ./reverse_piglattin_out_gpu_4000.csv \
|
| 79 |
--train_percentage 50
|
| 80 |
echo test 5
|
| 81 |
./venv/bin/python transmorgrify.py \
|
| 82 |
--execute \
|
| 83 |
+
--in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/piglattin/pig_lattin.csv \
|
| 84 |
--a_header English \
|
| 85 |
+
--b_header Piglattin\
|
| 86 |
--device cpu \
|
| 87 |
+
--model piglattin_gpu_4000.tm \
|
| 88 |
--verbose \
|
| 89 |
--include_stats \
|
| 90 |
+
--out_csv ./piglattin_out_gpu_4000.csv \
|
| 91 |
--train_percentage 50
|
| 92 |
|
run_tests2.sh
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# !/usr/bin/env bash
|
| 2 |
+
# echo test 1
|
| 3 |
+
# ./venv/bin/python transmorgrify.py \
|
| 4 |
+
# --train --in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/piglattin/pig_lattin.csv \
|
| 5 |
+
# --a_header English \
|
| 6 |
+
# --b_header Piglattin\
|
| 7 |
+
# --device 0:1 \
|
| 8 |
+
# --model piglattin_gpu_4000.tm \
|
| 9 |
+
# --verbose \
|
| 10 |
+
# --iterations 4000 \
|
| 11 |
+
# --train_percentage 50
|
| 12 |
+
# echo test 1b
|
| 13 |
+
# ./venv/bin/python transmorgrify.py \
|
| 14 |
+
# --train --in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/piglattin/pig_lattin.csv \
|
| 15 |
+
# --b_header English \
|
| 16 |
+
# --a_header Piglattin\
|
| 17 |
+
# --device 0:1 \
|
| 18 |
+
# --model reverse_piglattin_gpu_4000.tm \
|
| 19 |
+
# --verbose \
|
| 20 |
+
# --iterations 4000 \
|
| 21 |
+
# --train_percentage 50
|
| 22 |
+
# echo test 4
|
| 23 |
+
# ./venv/bin/python transmorgrify.py \
|
| 24 |
+
# --execute \
|
| 25 |
+
# --in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/piglattin/pig_lattin.csv \
|
| 26 |
+
# --a_header Piglattin\
|
| 27 |
+
# --b_header English \
|
| 28 |
+
# --device cpu \
|
| 29 |
+
# --model reverse_piglattin_gpu_4000.tm \
|
| 30 |
+
# --verbose \
|
| 31 |
+
# --include_stats \
|
| 32 |
+
# --out_csv ./reverse_piglattin_out_gpu_4000.csv \
|
| 33 |
+
# --train_percentage 50
|
| 34 |
+
# echo test 5
|
| 35 |
+
# ./venv/bin/python transmorgrify.py \
|
| 36 |
+
# --execute \
|
| 37 |
+
# --in_csv /home/lansford/Sync/projects/tf_over/sentance_transmogrifier/examples/piglattin/pig_lattin.csv \
|
| 38 |
+
# --a_header English \
|
| 39 |
+
# --b_header Piglattin\
|
| 40 |
+
# --device cpu \
|
| 41 |
+
# --model piglattin_gpu_4000.tm \
|
| 42 |
+
# --verbose \
|
| 43 |
+
# --include_stats \
|
| 44 |
+
# --out_csv ./piglattin_out_gpu_4000.csv \
|
| 45 |
+
# --train_percentage 50
|
| 46 |
+
#
|
transmorgrify.py
CHANGED
|
@@ -68,6 +68,8 @@ class Transmorgrifyer:
|
|
| 68 |
|
| 69 |
os.unlink( temp_filename)
|
| 70 |
|
|
|
|
|
|
|
| 71 |
|
| 72 |
def execute( self, from_sentances, verbose=False ):
|
| 73 |
for i,from_sentance in enumerate(from_sentances):
|
|
|
|
| 68 |
|
| 69 |
os.unlink( temp_filename)
|
| 70 |
|
| 71 |
+
return self
|
| 72 |
+
|
| 73 |
|
| 74 |
def execute( self, from_sentances, verbose=False ):
|
| 75 |
for i,from_sentance in enumerate(from_sentances):
|