ejschwartz commited on
Commit
9377434
·
1 Parent(s): 7e17e4e

Call helper

Browse files
Files changed (3) hide show
  1. README.md +1 -0
  2. app.py +9 -11
  3. requirements.txt +2 -1
README.md CHANGED
@@ -41,3 +41,4 @@ It's unclear why a1, a2, and result are not listed.
41
  ## Todo
42
 
43
  * Add field decoding (probably needs Docker)
 
 
41
  ## Todo
42
 
43
  * Add field decoding (probably needs Docker)
44
+ * ReSym's parser fails for functions with a name
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import gradio as gr
 
2
  import frontmatter
3
  import os
4
  import spaces
@@ -20,17 +21,7 @@ vardecoder_model = AutoModelForCausalLM.from_pretrained(
20
  # "ejschwartz/resym-fielddecoder", torch_dtype=torch.bfloat16, device_map="auto"
21
  # )
22
 
23
- example = r"""__int64 __fastcall sub_410D81(__int64 a1, __int64 a2, __int64 a3)
24
- {
25
- int v4; // [rsp+20h] [rbp-20h] BYREF
26
- __int64 v5; // [rsp+28h] [rbp-18h]
27
-
28
- if ( !a1 || !a2 || !a3 )
29
- return 0LL;
30
- v4 = 5;
31
- v5 = a3;
32
- return sub_411142(a1, a2, &v4);
33
- }"""
34
 
35
  examples = [
36
  ex.encode().decode("unicode_escape") for ex in open("examples.txt", "r").readlines()
@@ -80,6 +71,13 @@ def infer(code):
80
  skip_special_tokens=True,
81
  clean_up_tokenization_spaces=True,
82
  )
 
 
 
 
 
 
 
83
  # field_output = fielddecoder_model.generate(
84
  # input_ids=input_ids,
85
  # max_new_tokens=1024,
 
1
  import gradio as gr
2
+ from gradio_client import Client
3
  import frontmatter
4
  import os
5
  import spaces
 
21
  # "ejschwartz/resym-fielddecoder", torch_dtype=torch.bfloat16, device_map="auto"
22
  # )
23
 
24
+ gradio_client = Client("https://ejschwartz-resym-field-helper.hf.space/")
 
 
 
 
 
 
 
 
 
 
25
 
26
  examples = [
27
  ex.encode().decode("unicode_escape") for ex in open("examples.txt", "r").readlines()
 
71
  skip_special_tokens=True,
72
  clean_up_tokenization_spaces=True,
73
  )
74
+
75
+ field_helper_result = gradio_client.predict(
76
+ decompiled_code=code,
77
+ api_name="/predict",
78
+ )
79
+ print(field_helper_result)
80
+
81
  # field_output = fielddecoder_model.generate(
82
  # input_ids=input_ids,
83
  # max_new_tokens=1024,
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  transformers
2
  accelerate
3
- python-frontmatter
 
 
1
  transformers
2
  accelerate
3
+ python-frontmatter
4
+ gradio_client