Upload main.py with huggingface_hub
Browse files
main.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Save this as main.py in Colab
|
| 2 |
+
from kivy.app import App
|
| 3 |
+
from kivy.uix.boxlayout import BoxLayout
|
| 4 |
+
from kivy.uix.label import Label
|
| 5 |
+
from kivy.uix.textinput import TextInput
|
| 6 |
+
from kivy.uix.button import Button
|
| 7 |
+
from kivy.uix.image import Image
|
| 8 |
+
import requests
|
| 9 |
+
# Note: For the mobile app, we usually use a Cloud API for the "Brain"
|
| 10 |
+
# because running PyTorch on a phone requires massive storage.
|
| 11 |
+
# However, this UI shows the structure.
|
| 12 |
+
|
| 13 |
+
class AutomataApp(App):
|
| 14 |
+
def build(self):
|
| 15 |
+
layout = BoxLayout(orientation='vertical', padding=20, spacing=20)
|
| 16 |
+
|
| 17 |
+
self.lbl = Label(text="Neural Automata Mobile", font_size=30, color=(0,1,0,1))
|
| 18 |
+
layout.add_widget(self.lbl)
|
| 19 |
+
|
| 20 |
+
self.txt = TextInput(hint_text="Enter prompt (e.g. dfa ends with 01)", multiline=False, size_hint=(1, 0.2))
|
| 21 |
+
layout.add_widget(self.txt)
|
| 22 |
+
|
| 23 |
+
btn = Button(text="Generate Machine", size_hint=(1, 0.2), background_color=(0,0,1,1))
|
| 24 |
+
btn.bind(on_press=self.generate)
|
| 25 |
+
layout.add_widget(btn)
|
| 26 |
+
|
| 27 |
+
self.img = Image(source="")
|
| 28 |
+
layout.add_widget(self.img)
|
| 29 |
+
|
| 30 |
+
return layout
|
| 31 |
+
|
| 32 |
+
def generate(self, instance):
|
| 33 |
+
# In a real APK, this would call your logic locally or via API
|
| 34 |
+
# For demo purposes:
|
| 35 |
+
self.lbl.text = "Generating: " + self.txt.text
|
| 36 |
+
|
| 37 |
+
if __name__ == '__main__':
|
| 38 |
+
AutomataApp().run()
|