Spaces:
Running on Zero
Running on Zero
Private r8 standard Gradio browser baseline, synthetic tests only
Browse files- README.md +6 -6
- RELEASE_MANIFEST.json +3 -2
- app.py +56 -101
- make_test_inputs.py +27 -0
README.md
CHANGED
|
@@ -6,9 +6,9 @@ python_version: "3.10"
|
|
| 6 |
app_file: app.py
|
| 7 |
---
|
| 8 |
|
| 9 |
-
Private
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
Not
|
|
|
|
| 6 |
app_file: app.py
|
| 7 |
---
|
| 8 |
|
| 9 |
+
Private standard-Gradio browser baseline, synthetic tests only. No user upload interface.
|
| 10 |
+
No custom login, job access keys, or user result store in this diagnostic entrypoint.
|
| 11 |
+
Run explicitly through the Hugging Face Space page; GPU uses the visitor allowance.
|
| 12 |
+
Simulator by Zorro909: https://github.com/Zorro909/driving_sim_rs
|
| 13 |
+
HF implementation and UI by TiGa: https://github.com/seeker-cyber-maker/driving_sim_rs
|
| 14 |
+
Not a public release or a full trainer. Earlier custom-interface snapshots are preserved.
|
RELEASE_MANIFEST.json
CHANGED
|
@@ -5,8 +5,8 @@
|
|
| 5 |
"GODOT_LICENSE": "fb2b3bb82c60f1e76841ba2122eb902f8e39c151476fe21ce10c9a05d1045304",
|
| 6 |
"IMPORTER_BUILD_RECEIPT.json": "4ba5c533cc617105478e4d85c83f456a7dfa68b1388049624619871ba9e42e9d",
|
| 7 |
"LICENSE": "53d5851b6440feeae36f72a5f57fcab37858c48b7084765ece4b0c54b9a28ed8",
|
| 8 |
-
"README.md": "
|
| 9 |
-
"app.py": "
|
| 10 |
"app_release.py": "40cef7e65bbcf9798eaa1374a2c7be4bb45a5d4e70e981a1eeb8b0b2f2a00c35",
|
| 11 |
"assets/formula_template.json": "80f745df82bb7be45af52785fd582460bcddc63c5a4e1d8375d85b3122db4c6b",
|
| 12 |
"bin/altd-sim": "2f2f2144ae14b0ef599ca8510f95712da00243c6875881491d384b394e7499f7",
|
|
@@ -16,6 +16,7 @@
|
|
| 16 |
"delivery.py": "4f5a4e45df92e5cbfdef6eb449ede9ba26217fe24da376fafddae5cbbb73847a",
|
| 17 |
"gpu_tickets.py": "9e2cf757ddc46ca30b49cd6de07e5d84f328a858240afaad2e72453d24803f5a",
|
| 18 |
"index.html": "caeafcd208a638cd8c4235ca282b5b6451b81eb0e363fcfbb2ee02ed021a4db0",
|
|
|
|
| 19 |
"requirements.txt": "9b532747e51bd052e82090ece860d6dafe027407f4512dc74272c148ea104c22",
|
| 20 |
"server.py": "6375fb9f0a6ed39be0d7ce3cbe5c4c820e412e91417f424ad10a1b5f6f94062f",
|
| 21 |
"vendor/gradio-client/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4",
|
|
|
|
| 5 |
"GODOT_LICENSE": "fb2b3bb82c60f1e76841ba2122eb902f8e39c151476fe21ce10c9a05d1045304",
|
| 6 |
"IMPORTER_BUILD_RECEIPT.json": "4ba5c533cc617105478e4d85c83f456a7dfa68b1388049624619871ba9e42e9d",
|
| 7 |
"LICENSE": "53d5851b6440feeae36f72a5f57fcab37858c48b7084765ece4b0c54b9a28ed8",
|
| 8 |
+
"README.md": "905cadea3a2fe0042254d6b21093c256e3113e9a19592b7abf9a58d873c7c97c",
|
| 9 |
+
"app.py": "47605919270f695afd4a5b1ec477ab845014d4b95c57cf22855eba4d34233695",
|
| 10 |
"app_release.py": "40cef7e65bbcf9798eaa1374a2c7be4bb45a5d4e70e981a1eeb8b0b2f2a00c35",
|
| 11 |
"assets/formula_template.json": "80f745df82bb7be45af52785fd582460bcddc63c5a4e1d8375d85b3122db4c6b",
|
| 12 |
"bin/altd-sim": "2f2f2144ae14b0ef599ca8510f95712da00243c6875881491d384b394e7499f7",
|
|
|
|
| 16 |
"delivery.py": "4f5a4e45df92e5cbfdef6eb449ede9ba26217fe24da376fafddae5cbbb73847a",
|
| 17 |
"gpu_tickets.py": "9e2cf757ddc46ca30b49cd6de07e5d84f328a858240afaad2e72453d24803f5a",
|
| 18 |
"index.html": "caeafcd208a638cd8c4235ca282b5b6451b81eb0e363fcfbb2ee02ed021a4db0",
|
| 19 |
+
"make_test_inputs.py": "3c80813d63787877c071d0ba322dc444fea8a392705867a6965e16a30e104496",
|
| 20 |
"requirements.txt": "9b532747e51bd052e82090ece860d6dafe027407f4512dc74272c148ea104c22",
|
| 21 |
"server.py": "6375fb9f0a6ed39be0d7ce3cbe5c4c820e412e91417f424ad10a1b5f6f94062f",
|
| 22 |
"vendor/gradio-client/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4",
|
app.py
CHANGED
|
@@ -1,107 +1,62 @@
|
|
| 1 |
-
"""
|
| 2 |
-
|
| 3 |
-
Browser must invoke /gpu_train with @gradio/client for caller quota propagation.
|
| 4 |
-
The queue carries only an opaque ticket; result bytes stay in the existing store.
|
| 5 |
-
"""
|
| 6 |
-
import asyncio
|
| 7 |
-
import base64
|
| 8 |
-
from contextlib import asynccontextmanager
|
| 9 |
-
import json
|
| 10 |
-
import threading
|
| 11 |
import os
|
| 12 |
os.environ['GRADIO_ANALYTICS_ENABLED']='False'
|
|
|
|
|
|
|
| 13 |
import gradio as gr
|
| 14 |
import spaces
|
| 15 |
-
from
|
| 16 |
-
from
|
| 17 |
-
from
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
data.extend(chunk)
|
| 67 |
-
try:
|
| 68 |
-
body=json.loads(data)
|
| 69 |
-
track=base64.b64decode(body['track'],validate=True)
|
| 70 |
-
network=base64.b64decode(body['network'],validate=True)
|
| 71 |
-
track_input(track);network_input(network)
|
| 72 |
-
ticket=tickets.put(track,network,body.get('automatic',True))
|
| 73 |
-
return {'ticket':ticket,'expires_in_seconds':120}
|
| 74 |
-
except RuntimeError:raise HTTPException(429,'GPU input capacity reached') from None
|
| 75 |
-
except Exception:raise HTTPException(400,'Invalid GPU input') from None
|
| 76 |
-
finally:data.clear()
|
| 77 |
-
|
| 78 |
-
@app.api(name='gpu_train',concurrency_limit=1,concurrency_id='gpu',api_visibility='undocumented')
|
| 79 |
-
def gpu_train(ticket:str)->dict:
|
| 80 |
-
if not admission.acquire(blocking=False):raise ValueError('GPU worker busy')
|
| 81 |
-
try:
|
| 82 |
-
track,network,automatic=tickets.take(ticket)
|
| 83 |
-
payload,report=cuda_call(track,network)
|
| 84 |
-
return {**base.state.results.publish(payload,automatic),'backend':'gpu','report':report}
|
| 85 |
-
finally:admission.release()
|
| 86 |
-
|
| 87 |
-
# Existing download/status/ACK/delete and CPU routes use the same result store.
|
| 88 |
-
for route in base.router.routes:
|
| 89 |
-
if getattr(route,'path',None)!='/api/capabilities':app.router.routes.append(route)
|
| 90 |
-
for middleware in base.user_middleware:
|
| 91 |
-
app.add_middleware(middleware.cls,*middleware.args,**middleware.kwargs)
|
| 92 |
-
return app
|
| 93 |
-
|
| 94 |
-
def main():
|
| 95 |
verify_package()
|
| 96 |
for name in ('altd-sim','extract_saved_track'):(ROOT/'bin'/name).chmod(0o755)
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
def cuda(track,network):
|
| 100 |
-
return run_native(track,network,binary=ROOT/'bin/altd-sim',
|
| 101 |
-
importer=ROOT/'bin/extract_saved_track',scene_template=ROOT/'assets/formula_template.json',
|
| 102 |
-
gpu_library=ROOT/'bin/libaltd_gpu.so',with_report=True)
|
| 103 |
-
|
| 104 |
-
build_app(cuda).launch(server_name='0.0.0.0',server_port=7860,run_history=False,
|
| 105 |
-
enable_monitoring=False,show_error=False)
|
| 106 |
-
|
| 107 |
-
if __name__=='__main__':main()
|
|
|
|
| 1 |
+
"""Standard Gradio browser baseline: synthetic inputs only, no custom sessions."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import os
|
| 3 |
os.environ['GRADIO_ANALYTICS_ENABLED']='False'
|
| 4 |
+
import hashlib
|
| 5 |
+
import tempfile
|
| 6 |
import gradio as gr
|
| 7 |
import spaces
|
| 8 |
+
from app_release import ROOT,verify_package
|
| 9 |
+
from make_test_inputs import make
|
| 10 |
+
from worker import run_native
|
| 11 |
+
|
| 12 |
+
@spaces.GPU(duration=30)
|
| 13 |
+
def gpu_calculation():
|
| 14 |
+
import torch
|
| 15 |
+
value=torch.arange(16,device='cuda',dtype=torch.float32).sum().item()
|
| 16 |
+
if value!=120:raise RuntimeError('Unexpected GPU result')
|
| 17 |
+
return {'status':'PASS','test':'GPU arithmetic','sum':value,
|
| 18 |
+
'device':torch.cuda.get_device_name(0),'custom_sessions':False}
|
| 19 |
+
|
| 20 |
+
def simulator(gpu=False):
|
| 21 |
+
with tempfile.TemporaryDirectory(prefix='tiga-synthetic-') as directory:
|
| 22 |
+
p=make(directory)
|
| 23 |
+
payload,report=run_native((p/'synthetic.track').read_bytes(),
|
| 24 |
+
(p/'synthetic.evolution').read_bytes(),binary=ROOT/'bin/altd-sim',
|
| 25 |
+
importer=ROOT/'bin/extract_saved_track',scene_template=ROOT/'assets/formula_template.json',
|
| 26 |
+
gpu_library=ROOT/'bin/libaltd_gpu.so' if gpu else None,with_report=True)
|
| 27 |
+
receipt={'status':'PASS','test':'synthetic simulator','report':report,
|
| 28 |
+
'candidate_sha256':hashlib.sha256(payload).hexdigest(),'candidate_bytes':len(payload),
|
| 29 |
+
'custom_sessions':False,'user_uploads':False}
|
| 30 |
+
return receipt
|
| 31 |
+
|
| 32 |
+
@spaces.GPU(duration=90)
|
| 33 |
+
def gpu_simulator():
|
| 34 |
+
return simulator(True)
|
| 35 |
+
|
| 36 |
+
def cpu_simulator():
|
| 37 |
+
return simulator(False)
|
| 38 |
+
|
| 39 |
+
def build_demo():
|
| 40 |
+
with gr.Blocks(analytics_enabled=False) as demo:
|
| 41 |
+
gr.Markdown('''# AI Learns To Drive — browser baseline
|
| 42 |
+
Simulator by [Zorro909](https://github.com/Zorro909/driving_sim_rs).
|
| 43 |
+
HF implementation and UI by TiGa (seeker-cyber-maker).
|
| 44 |
+
|
| 45 |
+
Private diagnostic stage: standard Gradio interface, no custom login or job sessions.
|
| 46 |
+
Use this page inside Hugging Face while signed in. No personal token is requested.
|
| 47 |
+
No user uploads: the simulator generates disposable synthetic inputs and returns only a receipt.
|
| 48 |
+
GPU tests use your HF allowance. Nothing runs automatically. This is not the full trainer.
|
| 49 |
+
''')
|
| 50 |
+
result=gr.JSON(label='Test receipt')
|
| 51 |
+
for label,fn,name in [('1. Test GPU connection',gpu_calculation,'gpu_calculation'),
|
| 52 |
+
('2. Test CPU simulator',cpu_simulator,'cpu_simulator'),
|
| 53 |
+
('3. Test GPU simulator',gpu_simulator,'gpu_simulator')]:
|
| 54 |
+
gr.Button(label).click(fn,outputs=result,api_name=name,
|
| 55 |
+
concurrency_limit=1,concurrency_id='baseline')
|
| 56 |
+
return demo
|
| 57 |
+
|
| 58 |
+
if __name__=='__main__':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
verify_package()
|
| 60 |
for name in ('altd-sim','extract_saved_track'):(ROOT/'bin'/name).chmod(0o755)
|
| 61 |
+
build_demo().queue(max_size=1).launch(server_name='0.0.0.0',server_port=7860,
|
| 62 |
+
run_history=False,enable_monitoring=False,show_error=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
make_test_inputs.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Write disposable synthetic inputs, never copy a campaign track or trained network.
|
| 2 |
+
|
| 3 |
+
Track layout matches upstream print_saved_fixture's fixed generator output.
|
| 4 |
+
Tile IDs reference upstream resources: their provenance remains a release gate.
|
| 5 |
+
"""
|
| 6 |
+
import gzip
|
| 7 |
+
import json
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
import tempfile
|
| 10 |
+
|
| 11 |
+
def make(directory):
|
| 12 |
+
directory=Path(directory); directory.mkdir(parents=True,exist_ok=True)
|
| 13 |
+
cells=[(0,0,2,3),*( (x,0,5,0) for x in range(1,5)),(5,0,2,2),
|
| 14 |
+
(5,1,102,0),*((x,1,105,0) for x in range(4,0,-1)),(0,1,102,1)]
|
| 15 |
+
tiles={}
|
| 16 |
+
for x,y,atlas,alternative in cells:
|
| 17 |
+
coord=f'Vector2i({x}, {y})'
|
| 18 |
+
tiles[coord]={'Block':{'TileSetId':{'AtlasId':atlas,'AlternativeId':alternative}},'Coords':coord}
|
| 19 |
+
track={'Tiles':tiles,'StartTileCoords':'Vector2i(0, 0)',
|
| 20 |
+
'StartTileConnection':{'Side':3,'Index':1,'Type':0}}
|
| 21 |
+
network={'Name':'Synthetic smoke input','Type':0,'Outputs':[0,1],'Sensors':[{'$type':'speed'}],
|
| 22 |
+
'NeuralNetwork':{'Shape':[1,2],'Weights':[[[0.,0.]]],'Biases':[[0.,1.]]}}
|
| 23 |
+
for name,obj in [('synthetic.track',track),('synthetic.evolution',network)]:
|
| 24 |
+
(directory/name).write_bytes(gzip.compress(json.dumps(obj).encode(),mtime=0))
|
| 25 |
+
return directory
|
| 26 |
+
|
| 27 |
+
if __name__=='__main__': print(make(tempfile.mkdtemp(prefix='tiga-browser-fixtures-')))
|